Jaloliddin
Jaloliddin

Reputation: 5

Dark theme and light theme problem - android studio (night)

I will try to explain in detail‚ please help. I opened a new project‚ in the new project the "theme" section was opened twice‚ one light one dark. I added black text to the app ‚the text looked white because my phone is a dark theme. This is very good but incomprehensible. I only have one color.xml file (not for the night version) How did the text change to white? This is fine but the icon (vector ‚xml) I added and gave it a gray color ‚but now it was incomprehensible. The color of the icon changed from gray to black in the dark. I wanted him to change to white. I also opened for Colors.xml for the night. Now that I think there will be no mistakes, nothing has changed. The night is getting black in them.

  1. How can I make an icon (vector ‚xml) gray in light and white in the dark theme?
  2. I have a dark and light "theme" file ‚Do I have to separate the "colors" into dark and light themes?

I hope I was able to explain ‚Thank you so much!

Upvotes: 0

Views: 3213

Answers (1)

MG1616
MG1616

Reputation: 377

The text's color has changed to white because you didn't set a color, and it's inherits from the default android settings.

If you want to change (customise) the colors depending on the theme, I suggest you to override the colors.xml file for the night mode.

Declare the color that you want for your icon.

colors.xml

  <color name="iconColor">#FF808080</color>

colors.xml (night)

  <color name="iconColor">#FFFFFFF</color>

In your drawable, you must set this new color.

 android:fillColor="@color/iconColor"

It's also a good thing to override the others colors (primary, primaryLight, etc.) to lighter variants.

You can practice here if you want to exercise the theme changed on android (this is in Kotlin, but the same course exists in Java).

Upvotes: 1

Related Questions