Can The Tab Selection Indicator Of Tablayout Be Pinned To The Top Of The Screen While Scrolling?
Solution 1:
I think you should just have no flags at all. Your layout should be something like:
<CoordinatorLayout><AppBarLayout><Toolbarapp:layout_scrollFlags="scroll|enterAlways" /><TabLayout/></AppBarLayout>
< /> <!-- ViewPager or other stuff --></CoordinatorLayout>
If you assign the scroll
flag to the TabLayout
it will start reacting to scroll gestures and will move/enter/exit according to your flags. As far as I understand about your question, you don't want it to move, so just remove the flags.
See here for reference.
Solution 2:
You should provide your custom Behavior
for your TabLayout
or AppBarLayout
(only if TabLayout
is only child of the AppBarLayout
), where you will translate the y of the TabLayout
to the -mTabLayout.getHeight() + mTabIndicatorHeight
. You should do the same if you go with offseting top and bottom.
Currently, TabLayout
does not have @DefaultBehavior
and it is translated by the AppBarLayout
behavior. Which is plain top and bottom offseting to the total amount of scroll range (sum of heights of views that have scrolling flags).
Post a Comment for "Can The Tab Selection Indicator Of Tablayout Be Pinned To The Top Of The Screen While Scrolling?"