NestedScrollView嵌套ViewPager出现的滑动冲突
问题描述:
ViewPager无法左右滑动, 切无内容显示. 如果有相关Tab与ViewPager相绑定, 会导致Tab切换卡顿.问题布局复原:
<android.support.v4.widget.NestedScrollView
android:id="@+id/home_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
- 解决办法:
在相应Activity或Fragment中
NestedScrollView nestedScrollView = view.findViewById(R.id.home_scroll_view);
nestedScrollView.setFillViewport(true);
NestedScrollView中嵌套RecyclerView出现的滑动冲突
问题描述:
RecyclerView滑动出现卡顿问题布局复原:
<android.support.v4.widget.NestedScrollView
android:id="@+id/home_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.v4.widget.NestedScrollView>
- 解决办法:
在Activity或Fragment中, 为recyclerView设置如下代码:
recyclerView.setNestedScrollingEnabled(false);// 解决滑动冲突