-1

We are building an app that decides the color of the app based on the login. When someone logs in for a specific company we get the color codes from the API. Is it possible to use them as color resource?

Bart Bergmans
  • 4,061
  • 3
  • 28
  • 56

2 Answers2

1

You can't change colors at runtime, but there are some workarounds to do dynamic colors. Take a look at this question

Keep in mind that: If you do that, you & your designers will have ton of things to do to have contrast colors (colors on the background), color above another color,... This mean "You have to do theming for each color from api"

Robust
  • 2,415
  • 2
  • 22
  • 37
0

If you are getting color hex code as string you can do the following.

String colorCodeFromApi="#2222FF";    
int color = Color.parseColor(colorCodeFromApi);

you can put this color in some constant file and can use it when ever required.

If you are using data binding concept then you can create a binding adapter inside that you can set the color of the view.

Ritu Suman Mohanty
  • 734
  • 1
  • 6
  • 15