Issue
I have a BottomNavigationView* tab bar, and I want to set the background colour, however I don't have the colour until runtime. It appears as though setItemBackground requires a resource id.
Is there some way of creating a resource out of a GradientDrawable or something similar, then passing that new resource id?
Alternatively is there some other way of doing this without using XML that I've missed and would allow me to just pass a colour or Drawable?
It seems weird that this is so difficult...
*actually using BottomNavigationViewEx which is an extension of it from here, but it doesn't make much difference to my question: https://github.com/ittianyu/BottomNavigationViewEx
Solution
BottomNavigationViewEx inherits from View, which has a setBackground(Drawable drawable) method. Use that if you're trying to set the background. If you want to change the background of the items, you will have to either subclass or create a custom implementation of BottomNavigationViewEx as it doesn't look like it supports dynamically generated resources. But I don't see anything prohibiting such a thing.
Answered By - JitterbugChew
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.