我有 CollapsingToolbarLayout
,其滚动标志为 app:layout_scrollFlags="scroll|exitUntilCollapsed"
.
一旦用户向下滚动它就应该开始崩溃并完美地完成它 . 但是有一个问题:它必须在用户滚动到页面顶部时显示 .
如果用户在滚动时继续在屏幕上移动手指,它会按预期工作并显示折叠的内容,但如果用户手指在屏幕上,即使用户已向上滚动, CollapsingToolbarLayout
也不会显示可能 .
活动的Xml布局如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/home_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main.collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<include layout="@layout/plain_toolbar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollable_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="HI"
android:textSize="200dp" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<!--</FrameLayout>-->
</android.support.design.widget.CoordinatorLayout>
<fragment
android:id="@+id/main_activity_nav"
android:name="ir.flashcards.english.view.fragment.NavigationDrawerFragment"
android:layout_width="@dimen/nav_width"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fragment_navigation_drawer"
tools:layout="@layout/fragment_navigation_drawer"></fragment>
</android.support.v4.widget.DrawerLayout>
当我在屏幕上移动手指以便滚动开始并让它滚动直到它到达布局的顶部时,导航栏看起来像:
我应该手动拉动它,以便工具栏也可以扩展,如果我没有让我的手指离开屏幕并逐渐滚动工具栏会扩展如下: