admin管理员组

文章数量:1391960

I've created an app which is working as expected. The app is only running on an Android device with a dark mode theme, and should always appear dark.

I did notice one small visual bug I would like to solve. When the Android device has the "Force Dark mode" in the "Developer options" turned on, some of the objects (mostly vector images) change their color.

I would like to keep it on on my device, because of some other apps.

Here is an example of how an image should look (left), and how it looks with Force Dark mode (right):

After searching for a solution, I've tried modifying my style.xml file. I've been through many different styles with no effect.

I've also tried using the item "android:forceDarkAllowed" with both true and false values, again with no effect.

Here is my style.xml file:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <!-- Base application theme. -->
    <style name="ThemeOverlay.AppCompat.Dark.NoActionBar" parent="ThemeOverlay.AppCompat.Dark">
        <item name="android:forceDarkAllowed" >true</item>
        <item name="android:background">#00000000</item> <!-- Or any transparency or color you need -->
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:colorBackgroundCacheHint">@null</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
    </style>
</resources>

本文标签: androidDeveloper option force dark mode changes app colorsStack Overflow