Home > Software design >  Android - Theme.AppCompat.DayNight.NoActionBar adds gray line to top of activity
Android - Theme.AppCompat.DayNight.NoActionBar adds gray line to top of activity

Time:03-02

in themes.xml I defined custom theme extended from Theme.AppCompat.DayNight.NoActionBar

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.NoBackground" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="android:windowBackground">@null</item>
        <item name="android:windowSwipeToDismiss">false</item>
    </style>
</resources> 

This theme adds gray line on top of activity - see line over the text "Decompressing graphics files"

My application targets Android 12 and in build.gradle I use:

api 'com.android.support:appcompat-v7:27. '

Weird is that this line is not on all tested devices. On Samsung s20 fe is present, on Pixel 3XL is not. Both are on android 12.

My activity is set to fullscreen with:

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

EDIT: If I extend "android:Theme.NoTitleBar.Fullscreen" theme then gray line is gone on both devices. However, it breaks Dialog style on Pixel 3XL with android 12 (with android 11 it is ok). This was reason why I switch to AppCompat theme. The same issue was on Samsung s20 fe, but after last samsung update it was fixed.

How to remove it?

enter image description here

CodePudding user response:

Add this in themes and see if it works

<item name="android:windowFullscreen">true</item>

CodePudding user response:

I fixed it with this:

<style name="Theme.NoBackground" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="android:background">#00000000</item>
    <item name="android:windowBackground">#00000000</item>
    <item name="android:windowSwipeToDismiss">false</item>
</style>
  • Related