当标签页超过64个时,如何消除Android TV中的TabLayout滚动跳动(跳过)?

问题描述 投票:0回答:1

我正在尝试使用TabLayout在Android TV应用中实现标签导航。选项卡很多,因此我启用了“可滚动”模式。当我尝试浏览选项卡时(从左到右)使用遥控器,选项卡指示符不会移至下一个选项卡,而是会跳至右侧,一次又一次,直到到达某个位置。到达此位置后,选项卡指示器开始正常移动。

我做了一些实验,发现只有当TabLayout中的选项卡数大于64时,才会出现这种异常的滚动行为。>

首先,我在TabHost上遇到了这个问题,并将代码更改为使用TabLayout,但是问题仍然存在。我使用所有不同组合的相关选项,但均无效果。以下是我的布局文件的片段

<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>

我已经录制了视频,以显示它的外观:scroll_skipping.mp4

我想念什么?如何配置TabLayout以避免这种行为?

我正在尝试使用TabLayout在Android TV应用中实现标签导航。选项卡很多,因此我启用了“可滚动”模式。当我尝试浏览选项卡时(从左到右)...

android-tablayout android-tv
1个回答
0
投票

最后我找不到任何解决方案,它看起来像是Bug或TabLayout的限制。因此,我更改了布局,并使用ListView完成了我需要的工作。

© www.soinside.com 2019 - 2024. All rights reserved.