How do I make an activity full screen? Without the notification bar.
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. xml.
Full screen mode allows you to watch videos that take up your entire screen.
See the steps: Right click on your java main package > Select “New” > Select “Activity” > Then, click on “Fullscreen Activity”.
If you're using an app and want to toggle full screen on or off, you can do it from the recent apps list: Drag up from the bottom of the home screen, hold, then release. Or, touch if you're using 3-button navigation.
You can do it programatically:
public class ActivityName extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml
file:
<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
Edit:
If you are using AppCompatActivity then you need to add new theme
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
and then use it.
<activity android:name=".ActivityName"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
Thanks to https://stackoverflow.com/a/25365193/1646479
There's a technique called Immersive Full-Screen Mode available in KitKat.
Example
If you don't want to use the theme @android:style/Theme.NoTitleBar.Fullscreen
because you are already using a theme of you own, you can use android:windowFullscreen
.
In AndroidManifest.xml:
<activity
android:name=".ui.activity.MyActivity"
android:theme="@style/MyTheme">
</activity>
In styles.xml:
<style name="MyTheme" parent="your parent theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
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