You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android中ViewPager2内嵌RecyclerView横向滚动失效问题求助

ViewPager2中横向RecyclerView滚动失效问题

在ViewPager2的页面内实现横向RecyclerView时,RecyclerView无法正常进行横向滚动操作。

布局代码

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:paddingLeft="10dp"
    android:paddingRight="10dp">
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rvMusicList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        android:orientation="horizontal"
        tools:listitem="@layout/items_music"
        app:layout_constraintTop_toTopOf="parent"
        android:layout_marginTop="30dp"/>
...

Kotlin代码

rvBottomMenu.apply {
    layoutManager =
        LinearLayoutManager(this@MainActivity, RecyclerView.HORIZONTAL, false)
    adapter = bottomMenuAdapter
    setHasFixedSize(true)
}

已尝试过相关解决方案,但问题仍未解决。

内容的提问来源于stack exchange,提问作者Tousif Akram

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 09:42:52