【问题标题】:TabLayout Scroll and RecyclerView ScrollTabLayout 滚动和 RecyclerView 滚动
【发布时间】:2018-05-29 18:26:41
【问题描述】:

我正在使用带有 horizo​​ntal recyclerView

tabLayout

问题是当我滚动recyclerView时,tabLayout优先而不是RecyclerView。

只有当 tabLayout 位于最后一个 tab 时才会发生这种情况,tabLayout 不再滚动。

TabLayout 有这个属性

<android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="1dp"
            android:elevation="6dp"
            app:tabMaxWidth="0dp"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabSelectedTextColor="#ffffff"
            app:tabIndicatorColor="#ffffff"
            app:tabTextAppearance="@style/CustomTextStyle"
            >

我用属性 setHasFixedSize 设置了 recyclerView

recycler.setHasFixedSize(true)

这个 gif 显示了问题。

这里效果很好,因为tabLayout不在最后一个选项卡中。

【问题讨论】:

  • 你有没有在你的 recyclerview 上尝试 setnestedscrollingenabled(false)
  • 是的,我试过了,并没有改变任何东西。还是不行。
  • 有人吗?我仍然有问题...... recyclerView 在 ScrollView 内,而 scrollview 在 vi​​ewPager 内。我使用了 SetNestedScrollingEnabled(false) 但不起作用。

标签: android scroll android-recyclerview android-tablayout


【解决方案1】:

你没有提供完整的代码,所以我不能说你在哪里犯了错误。但希望下面几行可以帮助你

     LinearLayoutManager llm = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
        recyclerView.setLayoutManager(llm);
        recyclerView.setHasFixedSize(true);

之后,如果您从最右侧向左滑动,则选项卡也会在 recyclerview 之间切换。

【讨论】:

    猜你喜欢
    • 2020-03-17
    • 2018-06-10
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多