How to set full screen mode for activity in Android? I am using the following code to set full screen but it generates an error:
Exception:
android.util.AndroidRuntimeException:
requestFeature() must be called before adding content.
Code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Using Android Studio (current version is 2.2. 2 at moment) is very easy to add a fullscreen activity. See the steps: Right click on your java main package > Select “New” > Select “Activity” > Then, click on “Fullscreen Activity”.
Exit full screen Tap the video. At the bottom of the player, tap full screen exit .
This example demonstrate about How to get full screen activity in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
please check the code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
and note it is set before setting the content view
try this in AndroidManifest:
<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
put requestWindowFeature first in your code....like this...
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With