现有两个RecyclerView,每个都嵌套有NestedScrollView,部分代码如下
<android.support.v4.widget.NestedScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/global_activity_background_color">
<android.support.v7.widget.RecyclerView
android:id="@+id/goods_left_recycler_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
<android.support.v4.widget.NestedScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:background="@color/global_background_color_white">
<android.support.v7.widget.RecyclerView
android:id="@+id/goods_right_recycler_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.NestedScrollView>
运行截图如下:
我想点击左侧的item,右侧能滚动到相应位置,但是目前无任何响应,请问各位该如何解决。
1.首先我看到你的视图效果是完全不用嵌套使用,直接两个左右的Recycleview就可以了.如果非要外边包含一个Scroview的话,
__(1).解决嵌套滑动默认抢占焦点问题,在最外层父布局设置两个属性,
--(2)解决嵌套展示一条的问题以及滑动不流畅的问题,在Recycleview外边包一层Relativelayout,并设置属性 android:descendanFocusability="blocksDescendants"就可以解决