I want to make my activity full screen with status bar on top of it like this picture:
I have used this code in manifest
inside activity
tag:
'android:theme="@style/Theme.AppCompat.Light.NoActionBar"'
But my view doesn't start from the status bar & it looks like this:
How can I make my activity
look like the first one?
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”.
Status bar (or notification bar) is an interface element at the top of the screen on Android devices that displays the notification icons, minimized notifications, battery information, device time, and other system status details.
Immersive Mode, also known as full screen mode on Android, hides the status and navigation bars while using certain apps. Immersive Mode on Android is only enabled in certain apps by default, but there are ways to turn full screen mode on and off at will without rooting your device.
To customize it, first pull down the slider bar from the top of the screen. Next, tap on the three vertical dots in the top right corner. Now click on Status bar. You're in.
This will use the primaryDarkColor for the status bar. Dialog dialog = new Dialog (ctx, android.R.style.Theme_Black_NoTitleBar); This will display the status bar and remaining dialog will be full screen
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. In the above code, we have taken the digital clock view to show a clock.
While staying in full-screen mode, place your finger the top edge of your Android’s screen, and drag a wee bit downwards to reveal the status bar. Once the status bar is revealed, you can drag it all the way down to see the entire notification panel.
Note that the action bar is hidden too. You should never show the action bar without the status bar. Figure 2. Hidden status bar. You can hide the status bar on Android 4.0 (API level 14) and lower by setting WindowManager flags. You can do this programmatically or by setting an activity theme in your app's manifest file.
I know that the guy asking the question may have found his own solution but for the people who are still looking for a solution this is a very simple solution but one thing it has a limitation till Kitkat
so a condition is added
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }
Add these to your Base Application Theme in styles.xml
<item name="android:windowTranslucentStatus">true</item> <item name="android:windowTranslucentNavigation">true</item>
And add following attribute to your parent layout:
android:fitsSystemWindows="false"
Hope this helps.
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