-
Notifications
You must be signed in to change notification settings - Fork 0
How to use Force Dark ?
Devrath edited this page May 28, 2021
·
1 revision
- Make sure you are in
android-10
orabove
- Use the line below in the the application theme
<item name="android:forceDarkAllowed">true</item>
This is represented as
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:forceDarkAllowed">true</item>
</style>
- Now once you select the option
Dark Mode
in the taskbar, The dark theme is applied - If you want to exclude a
view
from theDark Mode
add the line below
android:forceDarkAllowed="false"
This is represented as
<Button
android:id="@+id/pressMeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/press_me"
android:forceDarkAllowed="false"/>