Android TabLayout with the active tab always in the center, as in the Play Newsstand app

In android.support.design.widget.TabLayout , how to make the active tab always appear in the center, exactly the same as in the Play Newsstand application, as shown below.

The first and last tab should also appear in the center.

Play newsstand

Play newsstand

I tried using padding in TabLayout. This does not work. This is the code I wrote:

 <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" app:tabIndicatorColor="@color/yellow" app:tabSelectedTextColor="@android:color/white" app:tabTextColor="#EEE" app:tabMode="scrollable" android:gravity="bottom" android:clipToPadding="false" android:paddingLeft="90dp" android:paddingRight="90dp" /> 

In this case, tabIndicator will also shift 90dp to the left. It should remain in the center regardless of filling.

+5
source share
1 answer

Reserve this solution: fooobar.com/questions/829760 / ...

It can be solved using tabContentStart, but if you want to center both sides of the Tablayout, you need to extend this class and install the add-on manually.

0
source

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


All Articles