关于scollview嵌套recyclerview

首先 scrollview 要放 fillViewport =true 让 子布局都能铺满整个屏幕

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:id="@+id/scrollview"
    android:fillViewport="true">

然后如果要嵌套recyclerview 必须包个布局,拦截 recyclerview获取焦点,这样  滑动的时候recyclerview不会跟scrollview抢焦点

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:descendantFocusability="blocksDescendants">
然后recyclerview的adapter 设置布局

View view = LayoutInflater.from(activity).inflate(R.layout.item_order_normal, null, false);
高度一定要wrap_content,里面子布局高度都要是这个wrap_content;

先写到这里,以后有想到在写.


猜你喜欢

转载自blog.csdn.net/xiexiaotian11/article/details/71192204