当前位置:网站首页>Methods of nested recycleview to solve sliding conflict and incomplete item display

Methods of nested recycleview to solve sliding conflict and incomplete item display

2022-04-23 18:42:00 Xiao Xiaofeng

nesting recycleview The problem is nothing more than these two : Slide conflict 、item Display incomplete . There are thousands of solutions , The simplest and most effective solution is as follows .

Slide conflict resolution :

to recycleview Set the following methods

recyclerView.setHasFixedSize(true);
recyclerView.setNestedScrollingEnabled(false);
       

Recycleview item The display is not completely solved :

Given in layout Recycleview Add... To the outer layer RelativeLayout And add properties android:descendantFocusability="blocksDescendants"

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:descendantFocusability="blocksDescendants">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:paddingTop="20pt"
            android:paddingBottom="20pt" />
    </RelativeLayout>

版权声明
本文为[Xiao Xiaofeng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210604091200.html