D
D
Danil Ochagov2018-10-12 17:17:10
Android
Danil Ochagov, 2018-10-12 17:17:10

How to change theme in android app?

Let's say I wrote an application, gave my colors to buttons, text, and other components. Then I do PreferencesActivity and add "change the theme" and a choice - light (default), dark, deepdark, green, etc. in this spirit. Then, if the user selects a topic, then how to do it? Apply a different color to each component? If you take a theme, then this is a set of ready-made things, and I have my own custom colors (this button is of this color, this button is of a different one, and when changing the theme, they should both change their colors to others). Is it really possible to prescribe a color for each component then based on the settings? I hope you got what I meant)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Varakosov, 2018-10-12
@thelongrunsmoke

Well, for example like this .

E
Egor, 2018-10-13
@RATlius

This will be a big problem if your colors are specified manually (in the xml markup file).
It is for such purposes that the res/values/color.xml file is used. You prescribe all the colors in it, and then change them as Alexander Varakosov
pointed out. It is not necessary to specify a color for each element. You can experiment and make mixtures of colors, and when you change the color, change only the main one and all shades will be saved if they are superimposed under translucent masks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question