您的位置:首页 > 其它

解决ScrollView+RecyclerView的滑动冲突问题

2018-01-17 09:42 369 查看
他们两个都是用来滑动的布局,两个用到一起难免会产生一些滑动的冲突,

一旦产生冲突就会影响到页面的美观,如何避免他们之间的冲突其实很简单,

一行代码就搞定了

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv">
</android.support.v7.widget.RecyclerView>

</LinearLayout>
</android.support.v4.widget.NestedScrollView>

</ScrollView>只需要在MainActivity加上一行
rv.setNestedScrollingEnabled(false);加上这一行就能完美的解决ScrollView和RecyclerView的滑动冲突了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐