Securing the android TabLayout Indicator to the Center

Asked 2 years ago, Updated 2 years ago, 139 views

How do I fix the indicator of TabLayout to the center of the screen like Google's news app?By default, the indicator moves to match the tab, but I want the indicator to be fixed in the middle so that the tab scrolls accordingly.

gole news app1
[gole news app 2[1]

xml

app:tabMode="scrollable"
   app:tabContentStart="72dp" 

I can do something like that in , but is there a solution for this: when the tab scrolls to the end to match ViewPager, the tab stops scrolling and the indicator starts to move instead (sorry, it's hard to explain in writing)?

android android-layout

2022-09-30 21:16

1 Answers

TabLayout seems difficult to achieve.

This is an introduction to the library, but if you use the Always In Center of this library, you will be able to achieve the desired behavior.
https://github.com/ogaclejapan/SmartTabLayout

SmartTabLayout

Also, if you want to use Google Newsstand-style layout, this library is convenient.
Of course, you can also specify the center of the tab.
https://github.com/florent37/MaterialViewPager


2022-09-30 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.