在appbarlayout下使用viewpager时,翻页功能无法正常工作。由于使用了
app:layout_scrollFlags="scroll"
,当下方的viewpager滚动时,appbarlayout应平稳地滚动到屏幕外。
请查看视频(12秒后):https://www.youtube.com/watch?v=_gY-7SiDiFs
这里是问题的gif演示:https://imgur.com/a/xHvDRhJ
非常感谢您的帮助。
以下是布局:<android.support.design.widget.CoordinatorLayout
android:id="@+id/detail_main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:elevation="0dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<FrameLayout
android:id="@+id/detail_thumbnail_root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/black"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:layout_collapseMode="parallax">
</FrameLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<RelativeLayout
android:id="@+id/fdsafsda123"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
app:layout_scrollFlags="scroll">
</RelativeLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<android.support.design.widget.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:background="@color/transparent_background_color"
app:tabBackground="@drawable/tab_selector"
app:tabGravity="center"
app:tabIndicatorHeight="0dp">
</android.support.design.widget.TabLayout>
</android.support.design.widget.CoordinatorLayout>
RecyclerView
。也许加上一个gif?此外,您是否尝试在真实设备上检查行为?这些标志符合预期吗?这可能是另一个问题.. - ʍѳђઽ૯ทapp:layout_scrollFlags="scroll|enterAlways|snap"
,看看可折叠视图会发生什么。 - ʍѳђઽ૯ท