项目场景:
在CoordinatorLayout为根布局,TabLayout放置在AppBarLayout内部,下面使用NestedScrollView包含一个ViewPager,实现水平滑动切换页面。页面如下图所示:
问题描述:
在tab标签显示的情况下,所有标签对应的Fragment均无法显示。
解决方案:
在NestedScrollView中设置fillViewport属性为true.
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.viewpager.widget.ViewPager
android:id="@+id/introduction_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.core.widget.NestedScrollView>