[英]NestedScrollview inside a Recycler view not scrolling
我正在创建一个Android程序。 在此程序中,我有一个ScrollView,其中有一个RecyclerView。 我正在通过RecyclerViewAdapter在此RecyclerView中添加数据。
对于RecyclerView的每个项目,都有一个NestedScrollview,它具有一个垂直方向的LinearLayout。 我在此LinearLayout中动态添加ImageView。
问题是图像没有滚动。 在极少数情况下(通过在屏幕上点击多次),它会滚动一次。
有人可以帮我吗?
这是代码-
家长回收站视图:-
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/id_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@color/gray3"
android:dividerHeight="5sp"
android:paddingLeft="2sp"
android:paddingTop="5sp"
android:paddingRight="2sp"/>
<com.app.sh.widget.WrappedGridView
android:id="@+id/gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/White"
android:numColumns="2">
</com.app.socialhand.widget.WrappedGridView>
</LinearLayout>
</ScrollView>
和回收者视图的项目:-
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vScrollView"
android:layout_below="@id/iv_up"
android:layout_above="@+id/iv_down"
android:isScrollContainer="true"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_123"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</LinearLayout>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
我正在ll_123中动态添加ImageViews。
尝试使用NestedScrollView而不是ScrollView或将其删除。 RecyclerView有自己的scrollview,它将与ScrollView冲突。
您可以尝试类似的结构:
<ScrollView>
<NestedScrollView>
<LinearLayout>
<RecyclerView/>
</LinearLayout>
</NestedScrollView>
</ScrollView>
并且ListItem布局应包含:
<NestedScrollView>
<LinearLayout/>
</NestedScrollView>
检查这是否正常工作...
我遇到了类似的问题,这对我有所帮助:
<ScrollView
android:id="@+id/messages_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/send_panel"
android:fillViewport="true"
android:padding="5dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:animateLayoutChanges="true"
android:gravity="center_horizontal|bottom"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
</ScrollView>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<-only one layout in nestade layout->
<LinearLayout
android:id="@+id/activity_edit_existing_location"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/rcl"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<-put here yr second layout code->
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.