Android 折叠工具栏布局和ViewPager
我正在折叠工具栏布局中使用ViewPager。Android 折叠工具栏布局和ViewPager,android,Android,我正在折叠工具栏布局中使用ViewPager。 问题是,当我滑动未完全展开的ViewPager时,工具栏标题会移动到应该处于完全展开状态的位置(默认情况下移动到左下角)。 然后在折叠后,标题完全消失 我的布局如下所示: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.c
问题是,当我滑动未完全展开的ViewPager时,工具栏标题会移动到应该处于完全展开状态的位置(默认情况下移动到左下角)。 然后在折叠后,标题完全消失 我的布局如下所示:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button_remember_word">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v4.view.ViewPager
android:id="@+id/pager_gallery"
android:layout_width="match_parent"
android:layout_height="240dp"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/text_word_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/tmp_lorem"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
添加两个屏幕截图:
1.正常扩展状态
任何建议都将不胜感激使用
app:layout\u collapseMode=“parallax”
查看页面
<android.support.v4.view.ViewPager
android:id="@+id/pager_gallery"
android:layout_width="match_parent"
app:layout_collapseMode="parallax"
android:layout_height="240dp"/>
您能显示工具栏状态的图片吗?添加了截图。幸运的是,它没有帮助您访问此链接吗?这可能对你有帮助
<android.support.v4.view.ViewPager
android:id="@+id/pager_gallery"
android:layout_width="match_parent"
app:layout_collapseMode="parallax"
android:layout_height="240dp"/>