tablayout set viewpager, has lot of tabs, mode_scrollable , keyline app:tabcontentstart="72dp".
when user selects tab, tablayout tries scroll selected tab center. selected tab left aligned keyline, not centered. possible?
android design support library v22.2.0.
unfortunately method calculatescrollxfortab() of tablayout private , not replaceable subclasses. either way can copy source tablayout in project, possibly extending class, , change method calculatescrollxfortab() this:
private int calculatescrollxfortab(int position, float positionoffset) { if (mmode == mode_scrollable) { view final selectedchild = mtabstrip.getchildat(position); // log.i ("scrollto" string.valueof ((int) selectedchild.getleft())); return (int) selectedchild.getleft(); } return 0; } this returns value of limit on left of tab selected, scrolling forced value. extreme right tabs remain fixed in position if selected because scroll clamps scrolling bounds of child.
i tried , works, although had solve 2 problems 1 compattextview not found in android.support.v7.internal.widget , method setupwithviewpager() not exist in source available me (i think matter of version)
Comments
Post a Comment