NestedScrollView包裹RecyclerView冲突问题

直接上代码地址

https://download.csdn.net/download/u012028250/24283805

主要实现NestedScrollview属性

//属性允许ScrollView中的组件填充满
android:fillViewport="true"

 布局文件代码

<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/snr_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>
</androidx.core.widget.NestedScrollView>

主要RecyclerView实现

//当我们确定Item的改变不会影响RecyclerView的宽高的时候可以设置setHasFixedSize(true)
mRecyclerview.setHasFixedSize(false);
//RecyclerView嵌套滚动启动效果设置为false
mRecyclerview.setNestedScrollingEnabled(false);

 业务代码

 mRecyclerview = findViewById(R.id.snr_recycler_view);
        //数据,一般从后台通过网络请求到
        list = new ArrayList<entity>();
        for (int i = 0; i < 15; i++) {
            list.add(new entity("Wade", "James", "Kobe"));
        }
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        mRecyclerview.setLayoutManager(layoutManager);
        mRecyclerview.setHasFixedSize(false);//重点
        mRecyclerview.setNestedScrollingEnabled(false);//重点
        //创建recyclerView的实例,并将数据传输到适配器
        sheetAdapter = new SheetAdapter(list);
        mRecyclerview.setAdapter(sheetAdapter);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值