skip to Main Content

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!

2

Answers


  1. 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

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search