miannelle
miannelle

Reputation: 2251

Android Simple way for User Color Selections

How can you change application colors on the fly?

I am currently using the following to change the background: LinearLayout mScreen = (LinearLayout) findViewById(R.id.main); mScreen.setBackgroundColor( mycolor );

I tried to use Style's to change the text using: @color/white

The problem is that Spinners/Buttons and Spinner-Popup-Lists all change to white text as well, making them unreadable. I have over 20 Classes in my app that all need to be able to change color combination's.

Upvotes: 1

Views: 239

Answers (1)

Roman Nurik
Roman Nurik

Reputation: 29745

One way to do this is to create several themes. To apply a theme at runtime, call setTheme in your activities' onCreate methods (before setContentView). You can force re-creation and thus re-theming of your activity by doing something like:

startActivity(getIntent());
finish();

Upvotes: 1

Related Questions