0

This is the home screen of my app. I have used Drawable and Color resources in the design. Now I want to have multiple color sets (for the parts with cyan color) so user can change them at run time. I searched a lot, but they don't fit my case.

Note that I want just the cyan colored parts to change. I know I can change all the TextView styles using style attribute, but I just need certain views get certain drawables or colors as background.

I found a solution here but I cannot use it because it needs the min sdk higher than 21 while mine is 16.

Home screen

sajjad
  • 834
  • 6
  • 13

2 Answers2

0

You can easily set theme like this:

public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.your_theme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity)
}
Amjad Alwareh
  • 2,926
  • 22
  • 27
0

Define your style in values/styles.xml like so:

<style name="AppTheme.MyTheme" parent="AppTheme.NoActionBar">
    <item name="colorPrimary">@color/primaryColorCyan</item>
    <item name="colorPrimaryDark">@color/primaryDarkColorCyan</item>
    <item name="colorAccent">@color/secondaryColorCyan</item>
</style>

And then call setTheme(R.style.MyTheme) before setContentView() in onCreate() method. setTheme introduced in API LEVEL 1.

Squti
  • 4,171
  • 3
  • 10
  • 21