I'm developing a program, but as I have the mobile phone in the dark theme, some textViews have a white letter and don't appear due to the color that is placed on them.
But when I switch the phone to the lightweight theme, the textView all appear.
I would like to know if it is possible to disable the dark theme in Android Studio and only use the light theme, even when the phone is set to a dark theme.
CodePudding user response:
In your themes.xml
your application theme's parent should be Theme.MaterialComponents.Light.NoActionBar
, or if you wan't to use the action bar (you shouldn't), then Theme.MaterialComponents.Light.DarkActionBar
CodePudding user response:
This is a kind of short term solution if you don't want to properly implement dark theme in your app (the one that comes to the entire OS after A10)
Set your android:textColor=@android:attr/textColorPrimary
which automatically choose the text color based on light or dark theme
Also, since you asked what to do to prevent from that default behaviour that switches your app to the dark mode when A10 and above devices turn on system wide dark mode then
You can make your Activity
theme a descendant of Theme.MaterialComponents.Light
or similar AppCompat
variant . Currently all apps use Theme.MaterialComponents.DayNight
which gives the default behaviour as above
If you decide to implement a system wide dark mode for your app, it's fairly easy, you can read about it here. Most of the widgets already come with dark mode support, it's just that you will have to do it for your own backgrounds etc