Is there an easy way to change the icon for the Android BottomBar
navigation (https://github.com/roughike/BottomBar). I have seen a number of ways to set this icon, but I would like to change the icon when the user selects it. Currently I have an icon, with outline, and I would like to display a filled icon when they select it. Any help would be great.
Change Android BottomBar Icon on Select
782 views Asked by BlackHatSamurai At
2
There are 2 answers
0
On
It looks like the guys at BottomBar
decided to incorporate this. They added the ability in 2.2.0:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_myicon_selected" android:state_selected="true" />
<item android:drawable="@drawable/ic_myicon_default" android:state_selected="false" />
</selector>
You can find the reference here.
There seems to be a getter and setter for the
iconResId
in the source file.Have you given that a go?
Create an object of BottomBarTab() and call this setter method in the OnItemSelected with your desired icon choice. https://github.com/roughike/BottomBar/blob/master/bottom-bar/src/main/java/com/roughike/bottombar/BottomBarTab.java#L175