调整内容大小以适应CollapsingToolbarLayout

问题描述 投票:0回答:1

我正在尝试创建一个布局,在CollapsingToolbarLayout中显示一个图形,并在一个包含一些数据的表格下方。我希望图表在启动时为全屏,然后您必须滚动才能看到数据。我目前正在做的是以下内容:

<LinearLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@color/colorPrimaryDark"
tools:context="de.glm9637.fengels.layouttest.DashboardActivity">

<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="160dp"
    android:layout_height="match_parent"/>

<android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <com.github.mikephil.charting.charts.LineChart
                android:id="@+id/chart1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_collapseMode="pin"
                android:fitsSystemWindows="true"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="112dp"
                app:layout_collapseMode= "parallax"/>

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_dashboard"/>


</android.support.design.widget.CoordinatorLayout>

哪个工作正常。但是现在我希望在工具栏折叠时调整LineChart的大小,因此它仍然可以在Top上显示。我怎么能归档这样的效果?

android android-collapsingtoolbarlayout
1个回答
0
投票

你可以用这个来实现

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

           <include layout="@layout/content_dashboard"/>

     </android.support.v4.widget.NestedScrollView>
© www.soinside.com 2019 - 2024. All rights reserved.