How to prevent Night Theme changing view colors to default colors in android studio?

530 views Asked by At

Actually it seems very easy. I just want my view not to change its color when DARK THEME is applied. But it keeps changing.

I have even created colors/night and edited theme/night to keep my colors.

For example, I have one ImageButton with white backgroud color. I want its background color stays unchanged even I apply dark theme. But It is getting black when Dark theme applied.

I have read so many answers. But it didn't work. Even some of them are still unanswered.

Is there any way to do that? Or is it some kind of bug?!

1

There are 1 answers

1
Husseinfo On

In app/src/main/res/values/themes.xml:

Replace DayNight

<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

With Light:

<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">