Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Making activity full screen with status bar on top of it

I want to make my activity full screen with status bar on top of it like this picture:

enter image description here

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:

enter image description here

How can I make my activity look like the first one?

like image 596
Utshaw Avatar asked Apr 20 '17 05:04

Utshaw


People also ask

How do I make my Android activity full screen?

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”.

What is the bar at the top of Android called?

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.

What is immersive mode Android?

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.

How can I customize my Android status bar?

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.

How to make the status bar full screen in Android?

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

How to get full screen activity in Android?

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.

How do I view notifications in full screen mode on Android?

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.

How to hide the action bar without the status bar?

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.


2 Answers

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); } 
like image 151
Vishwajit Palankar Avatar answered Oct 14 '22 10:10

Vishwajit Palankar


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.

like image 32
tahsinRupam Avatar answered Oct 14 '22 10:10

tahsinRupam