RecyclerView match_parent 不起作用的解决方法

本文详细阐述了如何使用@override注解实现自定义ViewHolder的onCreateViewHolder方法,包括视图的加载、布局参数的设置及返回ViewHolder实例的过程。


1  

@Override
public RecordViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Log.i(TAG, "onCreateViewHolder: ");
    view = mLayoutInflater.inflate(R.layout.item_check_info, null, false);
    RecyclerView.LayoutParams lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    view.setLayoutParams(lp);
    return new RecordViewHolder(view);
}

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.shehuan.statusview.StatusView android:id="@+id/statusView" android:layout_width="match_parent" android:layout_height="match_parent"> <com.scwang.smartrefresh.layout.SmartRefreshLayout android:id="@+id/smartRefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:overScrollMode="never" app:srlFooterTranslationViewId="@id/video_rv"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:outlineProvider="paddedBounds" android:background="@color/transparent" app:elevation="0dp"> <com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/toolbarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/home_rv" android:layout_width="match_parent" android:layout_height="match_parent" android:overScrollMode="never" /> </com.google.android.material.appbar.CollapsingToolbarLayout> <androidx.recyclerview.widget.RecyclerView android:id="@+id/type_rv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:layout_marginBottom="8dp" android:layout_marginRight="12dp" android:layout_marginLeft="12dp" app:layout_collapseMode="pin"/> </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.shehuan.statusview.StatusView android:id="@+id/statusView1" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/video_rv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginRight="8dp"/> </com.shehuan.statusview.StatusView> <View android:layout_width="match_parent" android:layout_height="61dp" /> </LinearLayout> </androidx.core.widget.NestedScrollView> </androidx.coordinatorlayout.widget.CoordinatorLayout> </com.scwang.smartrefresh.layout.SmartRefreshLayout> </com.shehuan.statusview.StatusView> </LinearLayout> home_rv的滑动监听不起作用怎么解决
12-28
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.shehuan.statusview.StatusView android:id="@+id/statusView" android:layout_width="match_parent" android:layout_height="match_parent"> <com.scwang.smartrefresh.layout.SmartRefreshLayout android:id="@+id/smartRefreshLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:overScrollMode="never" app:srlFooterTranslationViewId="@id/video_rv"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.material.appbar.AppBarLayout android:id="@+id/appBar" android:layout_width="match_parent" android:layout_height="wrap_content" android:outlineProvider="paddedBounds" android:background="@color/transparent" app:elevation="0dp"> <com.google.android.material.appbar.CollapsingToolbarLayout android:id="@+id/toolbarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/home_rv" android:layout_width="match_parent" android:layout_height="match_parent" android:overScrollMode="never" /> </com.google.android.material.appbar.CollapsingToolbarLayout> <androidx.recyclerview.widget.RecyclerView android:id="@+id/type_rv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" android:layout_marginBottom="8dp" android:layout_marginRight="12dp" android:layout_marginLeft="12dp" app:layout_collapseMode="pin"/> </com.google.android.material.appbar.AppBarLayout> <androidx.core.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" android:fillViewport="true"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.shehuan.statusview.StatusView android:id="@+id/statusView1" android:layout_width="match_parent" android:layout_height="match_parent"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/video_rv" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="8dp" android:layout_marginRight="8dp"/> </com.shehuan.statusview.StatusView> <View android:layout_width="match_parent" android:layout_height="61dp" /> </LinearLayout> </androidx.core.widget.NestedScrollView> </androidx.coordinatorlayout.widget.CoordinatorLayout> </com.scwang.smartrefresh.layout.SmartRefreshLayout> </com.shehuan.statusview.StatusView> </LinearLayout> 根据我的代码实现监听id为home_rv的滑动事件
最新发布
12-28
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值