Force full screen and rotate landscape Android

The following example is to force Android screen to become full screen programmatically. And to rotate into lanscape mode.

public class HijrahRasul_mula extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//no big screen title + icon
requestWindowFeature(Window.FEATURE_NO_TITLE);
//full screen without notification bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
//this is to force layout to landscape - for potrait chage to SCREEN_ORIENTATION_POTRAIT
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.activity_hijrah_rasul_mula);
}
}

 

There’s another alternative method by setting the Activity theme.

<application 
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

Android Emulator Output


full-screen-rotate-landscape-android


To rotate the Android emulator, hit CTRL+F12.


force-rotate-emulator-to-landscape-android

Popular Posts

WorldConferences.net