Android: Use different drawables after choosing a different theme, keeping the same references
Is possible to make the app use d开发者_运维问答ifferent drawables after choosing a theme in Android?
An explanatory example:
i have a layout which background uses a reference to: "@drawable/backgroundsolid", that is image backgroundsolid.png in res/drawable-mdpi.
I want that, if the user choose "Glass" theme, the reference stays to "@drawable/backgroundsolid" but the resources folder is changed to res/drawable-glass, which contains a different backgroundsolid.png image.
Is it possible to set this programmatically? Thanks a lot!
You can set it programmatically by using view.setBackgroundResourceId()
. I am not sure if you do it the other way which is let android pick the right theme for you. Maybe someone else has a better answer
精彩评论