Search code examples
androidpalette

Theme from Palette


I'm making an app that retrieve a lot of images from some server. I'm tinting each item in my List using Palette library. When a choose one I open another activity to show details of this item.

I want to build a theme based on the selected theme to apply in detail activity.

Is there a way to programmatically build a theme based on a Palette from a Bitmap?


Solution

  • If it is about the color of material design, there is a solution.

    1. Remember: You cannot change the modify those colors at runtime but you can switch between themes at activity start.
    2. When an user select a color, apply corresponding style and restart activity. Otherwise, change some other colors like Google keep
    3. To set theme .

      super.onCreate(savedInstanceState); setTheme(...style.YourTheme);

    4. To restart activity: Call the recreate() method of the activity.