Philip
Philip

Reputation: 69

How can I stop dark mode from messing up how my app looks?

I am a student trying to learn app development with android studio. For my first project, im just building a basic calculator app. I have stumbled across a problem that I couldnt solve and didnt find a helpfull post about. It occurs when I trun on dark mode on the virtual device. Here are 2 pictures showing what happens.

How it looks with dark mode

How it is supposed to look

My activity_main.xml consists of some buttons that all have the same style and a TextView. I left all the other files untouched. Id love some advice on how to fix this. Thanks for reading!

Upvotes: 1

Views: 2293

Answers (2)

tintin
tintin

Reputation: 385

there are two themes : night and not night check in IDE Design tab you can view how it looks in both click the circle in pane where design is displaying it displays Not Night and Night whatever theme you are using it will affect because of these two modes, by default IDE shows not night

To show screen same in both modes you need to change some settings like in your activity_main.xml at root layout change background to @color/white and see what happens it should be sorted out since your button colors are dark ...the text Placeholder color needs to be changed accordingly

<LinearLayout
background=@color/white


other layout etc to follow

Upvotes: 1

Tyler V
Tyler V

Reputation: 10910

You are most likely using the following default DayNight theme in your themes.xml file (values/themes/themes.xml)

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

If you don't want things to change in night mode, you can change that to use the Light theme instead

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

and delete the themes.xml (night) file if it exists. There is some extra info about these options here

Upvotes: 2

Related Questions