Android Pager Sliding lining with icons

I am developing an application for Android, and recently we decided to mix the design and switch our main screen to a pager with tabs at the top (actually in the action bar). To place the tabs at the top, I thought about using a custom action bar layout, and for the tabs I use the PagerSlidingTabStrip library , but I also need to have the text instead, to have an icon that changes color when scrolling (if the page is selected), since it is used in Facebook or Tinder app 1

Does anyone have any suggestions? I saw that there was a branch in the tab library that was supposed to do just that, but I couldn't get it to work.

+6
source share
1 answer

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 :).

+6
source

Source: https://habr.com/ru/post/980998/


All Articles