0

Is it possible to get the ActionBar's colour?

I'm wanting to change the actionbar's colour depending on what I'm looking at (like Google Play). There's going to be at least 8 different colours I need to toggle between, and I'd rather not have to manually keep track of the colour if possible.

Thanks

TMH
  • 6,096
  • 7
  • 51
  • 88
  • There you go, hope it helps http://stackoverflow.com/questions/17076958/change-actionbar-color-programmatically-more-then-once – Angmar Jan 22 '14 at 16:21
  • That's setting the color, which I can do fine, I need to get it's current colour if possible – TMH Jan 22 '14 at 16:29

1 Answers1

0

Why do you need to actually get the colour? I mean, if you're setting it either way, it doesn't matter if you set the colour as the actual colour, does it? You should only need the current section of the actionBar and the colour to which you're changing, am I wrong?

Angmar
  • 599
  • 4
  • 9
  • That's the way I ended up doing it, just keeping the colour in a variable when I change it and using that next time, I just though if I can get it dynamically there's less room for error. – TMH Jan 22 '14 at 18:02
  • that's very good for you, it's great to be perfectionist. But, the only way to do this dynamically is to compare the section where you are with a number or String and that is slower than just setting the colour. Leave the dynamic stuff to Adapters and Views. You should only consider changing your code if the UI freezes, but I think setting a colour does not freezes de UI does it? – Angmar Jan 23 '14 at 07:50
  • NAh setting the colour doesn't freeze it – TMH Jan 23 '14 at 08:40
  • Then you don't need to do any more work than needed, good luck with your app! – Angmar Jan 23 '14 at 09:03