【发布时间】:2018-01-27 14:58:18
【问题描述】:
我想在可滚动的RecyclerView 中创建一个可滚动的LinearLayout(我正在向其中动态添加项目)。在启动时,我最初可以看到一个小滚动条(表明它是一个可滚动的视图,在几秒钟内消失)。尝试了 appCompat NestedScrollView 以及启用nestedScrollingEnabled,但没有成功。如何使LinearLayout 在RecyclerView 内滚动?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<ScrollView
android:layout_width="wrap_content"
android:layout_height="300dp"
android:fillViewport="true"
android:nestedScrollingEnabled="true">
<LinearLayout
android:id="@+id/playerlist_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center_vertical"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="7dp"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
</FrameLayout>
回收站查看代码
<android.support.v7.widget.RecyclerView
android:id="@+id/messagesListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:nestedScrollingEnabled="false"/>
更新:我发现滚动确实有效,但前提是我向鼠标发送垃圾邮件或在滚动视图内快速点击。只要按住鼠标,它就会变得专注并允许滚动。真奇怪。
【问题讨论】:
-
添加你的 RecylerView 布局代码...
-
添加了 RecyclerView 代码。