android解决RecyclerView嵌套在NestedScrollView中在解决滑动冲突问题后出现子项显示不全

android解决RecyclerView嵌套在NestedScrollView中在解决滑动冲突问题后出现子项显示不全的问题。

1.解决滑动冲突的问题在代码中下入:

recycler.setHasFixedSize(true);

recycler.setNestedScrollingEnabled(false);

但是会出现recyclerview的子项显示不全的问题,这时候只需要在布局中:

<android.support.v4.widget.NestedScrollView

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:fillViewport="true">

<RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:descendantFocusability="blocksDescendants">

<android.support.v7.widget.RecyclerView

            android:id="@+id/rv_data_list"

            android:layout_width="match_parent"

            android:layout_height="match_parent"

            android:overScrollMode="never" />

如上给RecyclerView和NestedScrollView之间给RecyclerView加一层父布局,但是这个父布局只能是RelativeLayout,而不能用比较新的ConstraintLayout,

然后在RelativeLayout加入 android:descendantFocusability="blocksDescendants"即可。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容