0

im using android:Theme.NoTitleBar.Fullscreen in my styles.xml and everything works fine with most phones. but on some phones with front camera/ear speaker under the screen (like xiaomi redmi note 7) it doesn't get fullscreen(statusbar is still there but with no status and its color is dark). when i use <item name="android:statusBarColor">@color/myColor</item> while the parent theme is full screen it doesn't work and can't change the statusbar color, neither through java nor xml. (android:colorPrimaryDark doesnt affect statusbar color too when fullscreen theme is in effect)

How can i keep the theme fullScreen for all phones and at the same time only change the statusbar color for these types of phones? should i compare (app window height + navigation bar height) < real screen height and then set the theme based on the result?

(my immediate solution was using fullscreen for all api below 26 and since phones with this underscreen hidden/nonhidden camera feature come with android apis above 26 and have bigger screens i used notitlebar theme without fullscreen and then changed statusbar color)

  • Hello and Welcome to Stackoverflow. Please post your code in your question. So that we can check for any issues. Also it would be helpful if you post any picture of the issue. – Dharmaraj Apr 29 '20 at 11:38

1 Answers1

1

First of all you need change your theme in your styles.xml. For that you can use some of AppCompat themes with no action bar means you will then have full screen only with status bar on the top. You can use for example this theme in your styles.xml:

 <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

In the same xml file you can then use this code:

<item name="android:statusBarColor">@color/colorAccent</item>
<item name="android:windowLayoutInDisplayCutoutMode">
shortEdges 
</item>

If you already have this code in your styles.xml plese remove it because you will still have black cutout area:

<item name="android:windowFullscreen">true</item> <---REMOVE THIS CODE
Dezo
  • 835
  • 9
  • 16