1 我正在尝试将 CollapsingToolbarLayout 与 ScrollView 一起使用,但我不知道为什么它不起作用。我试试这个:
<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.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="256dp">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsingToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"
app:layout_scrollFlags="scroll|enterAlways"></include>
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/graph"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:background="@color/white"></com.github.mikephil.charting.charts.LineChart>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/nested_scroll_view" />
</android.support.design.widget.CoordinatorLayout>
我的嵌套滚动视图,其行为设置为 appbar_scrolling_view_behavior
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="10dp">
<include layout="@layout/scroll_view_aba"/>
<include layout="@layout/scroll_view_aci"/>
<include layout="@layout/scroll_view_aci_reduced"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
我的nestedScrollView 被滚动,但折叠工具栏被固定!