Method one code setting
Import Android.content.pm.ActivityInfo;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
Setrequestedorientation (Activityinfo.screen_orientation_landscape);
}
Description
GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);// Set up screen mode
Setrequestedorientation (Activityinfo.screen_orientation_landscape);//force for horizontal screen
Setrequestedorientation (activityinfo.screen_orientation_portrait);//Vertical screen
Method Two is configured by activity in the Androidmanifest.xml file
<activity
Android:name= "Com.example.testlinear.MainActivity"
android:screenorientation= "Landscape"
Android:label= "@string/app_name" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Android Setting horizontal screen vertical screen