开发笔记——ScrollView嵌套RecyclerView滑动冲突

解决ScrollView嵌套RecyclerView时滑动冲突问题

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none">
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:descendantFocusability="blocksDescendants"
            android:orientation="vertical">
            <android.support.v7.widget.RecyclerView
                android:id="@+id/recycler_view"
                android:layout_below="@id/tv_shared_user"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="@dimen/w_20px"
                android:layout_marginLeft="@dimen/w_65px"/>
    </RelativeLayout>
</ScrollView>

只需要在 RecyclerView外层单独加上RelativeLayout,RecyclerView就能正常显示,然后给RecyclerView设置属性:

 android:descendantFocusability="blocksDescendants"

解决RecyclerView和ScrollView焦点抢占导致的滑动冲突。

猜你喜欢

转载自blog.csdn.net/memory_of_the_wind/article/details/80743399