Search code examples
colorsnativescript

Theme Problem when Dark Mode is activated under MIUI 11 / 12


EDIT: MIUI force Dark Mode to be activated in my app, so the app looks awful.

In some Part of my app when I set Color to "white", it will be shown as White.

If I set it as "gray", it will be shown as Gray.

If I set it as "red", it will be shown as Red.

but: If I set it as "black", it will be "WHITE!"

How can I solve this problem??


Solution

  • Solution is Found!

    Setting false to the <item name="android:forceDarkAllowed">true</item> in App_Resources/Android/src/main/res/values/styles.xml

    Thanks to this link: https://medium.com/@kivind/nativescript-disabling-dark-mode-382e5dfd11bd

    so style.xml should looks like:

        <style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>
            <item name="android:forceDarkAllowed">false</item>
            <item name="colorPrimary">@color/ns_primary</item>
            <item name="colorPrimaryDark">@color/ns_primaryDark</item>
            <item name="colorAccent">@color/ns_accent</item>
        </style>