我有一个问题CollapsingToolbarLayout
。我不想滚动NestedScrollView
到最后,因为如果内容(在我的情况下为文本)很短,它会留下很多空白。以下是截图:
和:
这是 XML:
<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:id="@+id/coordinator"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_description"
>
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<android.support.v4.view.ViewPager
android:id="@+id/image_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/dots_holder" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="15dp"
android:id="@+id/dots_holder"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:gravity="center"
android:layout_alignParentBottom="true"
android:visibility="gone" />
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:padding="8dp"
android:id="@+id/nested_scrollView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="@+id/name"
android:textSize="@dimen/abc_text_size_headline_material"
android:textColor="@color/abc_primary_text_material_light" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="@+id/othernames"
android:layout_below="@+id/name"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@color/secondary_text_default_material_light" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="first"
android:id="@+id/season_head"
android:layout_alignParentBottom="false"
android:layout_alignParentLeft="false"
android:layout_below="@+id/othernames"
android:layout_marginTop="12dp"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@color/abc_primary_text_material_light" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="second"
android:id="@+id/places_head"
android:layout_marginTop="12dp"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@color/abc_primary_text_material_light"
android:layout_below="@+id/season" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="@+id/season"
android:layout_below="@+id/season_head"
android:layout_marginTop="@dimen/desc_clauses_margin"
android:textSize="@dimen/abc_text_size_body_1_material"
android:textIsSelectable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="@+id/places"
android:layout_below="@+id/places_head"
android:textSize="@dimen/abc_text_size_body_1_material"
android:layout_marginTop="@dimen/desc_clauses_margin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="third"
android:id="@+id/description_head"
android:textSize="@dimen/abc_text_size_subhead_material"
android:textColor="@color/abc_primary_text_material_light"
android:layout_below="@+id/places"
android:layout_marginTop="12dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TEXT"
android:id="@+id/description"
android:layout_below="@+id/description_head"
android:textSize="@dimen/abc_text_size_body_1_material"
android:layout_marginTop="@dimen/desc_clauses_margin" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
我想在内容结束时停止滚动。