OK, I found how to add an image to a tab, I had to go through the PagerSlidingTab library code a bit.
PagerSlidingTab contains the IconTabProvider interface, which must be implemented by your ViewPager adapter. This is implemented and for each position you can provide a different icon.
My only problem now is that I need to have a different color icon based on the selection or absence of a bookmark, with a slow transition between them (just like on Tinder and on Facebook).
LE: Apparently, lucky, and there is a tab tab library fork, which can be found here . You just need a resource that you can create in this way:
<item android:state_selected="true" android:drawable="@drawable/ic_twitter"/> <item android:drawable="@drawable/ic_twitter_of"/>
It will change whenever you select a new page, but there is no smooth transition between the on and off icon.
LE 2:
I found another branch that has a smooth transition to tabs (uses the alpha property to show a good transition), and it can be found here . The only problem is that it does not support the status switching icon, so I decided to combine the two forks. Thanks to both creators for their amazing work, I had a lot of time :).
source share