Android: use different images after choosing a different theme, keeping the same links

Is it possible for an application to use various drawings after selecting a theme in Android?

Example:

I have a layout in which the background refers to: "@ drawable / backgroundsolid", that is, the image backgroundsolid.png in res / drawable-mdpi .

I want that if the user selects the theme "Glass", the link remains to "@ drawable / backgroundsolid", but the resource folder changes to res / drawable-glass , which contains another backgroundsolid.png.

Can I install it programmatically? Thank you very much!

+4
source share
1 answer

You can set it programmatically using view.setBackgroundResourceId() . I'm not sure if you do it in another way that allows the android to choose the right theme for you. Maybe someone has a better answer

0
source

Source: https://habr.com/ru/post/1332921/


All Articles