Reputation: 158
I’m trying to implement tab navigation in my Android TV app using TabLayout. There are many tabs so I have enabled “scrollable” mode. When I'm trying to navigate through the tabs (from left to right) using remote control the tab indicator does not move to the very next tab but jumps far to the right, and again and again until it reaches some position. After this position is reached, tab indicator start moving normally.
I have experimented a little and found that this abnormal scrolling behavior appears only when number of tabs in TabLayout is more than 64
First I met this problem with TabHost and changed my code to use TabLayout, but problem persists. I have played with all relevant options with different combinations but nothing worked. Below is the fragment of my layout file
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@color/black_opaque"
android:fillViewport="true"
android:measureAllChildren="true"
android:nestedScrollingEnabled="false"
android:padding="2dp"
app:tabGravity="center"
app:tabMode="scrollable"
app:tabTextAppearance="@style/TextAppearance.AppCompat.Medium" />
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
I have recorded the video to show how it looks like: scroll_skipping.mp4
What do I missing? How to configure TabLayout to avoid such behavior?
Upvotes: 0
Views: 317
Reputation: 158
Finally I couldn’t find any solution, it looks like bug or TabLayout limitation. So I have changed the layout and did what I need with ListView.
Conclusion - TabLayout is for limited number of tabs, no more than 64, less is better.
Upvotes: 0