How to avoid forced dark theme in my app when devices can force it at app level?

落花浮王杯 提交于 2020-11-28 02:49:39

问题


Some devices, like Poco F2 Pro, can force dark theme in apps that are not compatible with dark theme.

For example, my app has this theme and is not compatible with dark theme:

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

This is my manifest application part, no dark theme enabled:

<application
    android:name=".helpers.CustomApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:largeHeap="true"
    android:theme="@style/AppTheme">

The problem is that devices like Poco F2 Pro, when forcing dark theme in apps, makes my app to be displayed with incorrect and abnormal colors, breaking the UI.

Can that be avoided?

How to force dark theme: https://www.androidauthority.com/android-q-force-dark-mode-984090


回答1:


you can Disabling Force Dark in your app by setting the theme as:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
   <item name="android:forceDarkAllowed">false</item>


来源:https://stackoverflow.com/questions/63777438/how-to-avoid-forced-dark-theme-in-my-app-when-devices-can-force-it-at-app-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!