1

我在CollapsingToolbarLayout中的應用程序中使用CollapsingToolbarLayout我們有一個工具欄和一個圖表,使用MPAndroid圖表繪製x和y點......無論如何,問題在於工具欄是在圖表上,我們看不到圖表(操作欄的尺寸完全相同),我怎麼可以把工具欄下面我的圖表視圖的頂部,則是我的代碼:在CollapsingToolbarLayout圖表在工具欄後面

<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="300dp"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapsingToolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="true" 
     android:foregroundGravity="bottom|right" 
     android:foregroundTintMode="add" 
     app:contentScrim="?attr/colorPrimary" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="@color/ColorPrimary" 
      android:elevation="5dp" 
      app:layout_collapseMode="pin" 
      app:theme="@style/Toolbar"> 
     </android.support.v7.widget.Toolbar> 

     <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" 
      app:layout_collapseMode="parallax"> 
     </com.github.mikephil.charting.charts.LineChart> 
    </android.support.design.widget.CollapsingToolbarLayout> 
</android.support.design.widget.AppBarLayout> 

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

回答

2

重新組織您的CollapsingToolbarLayout設置下面的工具欄LineChart

<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="300dp"> 

     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsingToolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:clipToPadding="true" 
      android:foregroundGravity="bottom|right" 
      android:foregroundTintMode="add" 
      app:contentScrim="?attr/colorPrimary" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

      <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" 
       app:layout_collapseMode="parallax"> 
      </com.github.mikephil.charting.charts.LineChart> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="@color/ColorPrimary" 
       android:elevation="5dp" 
       app:layout_collapseMode="pin" 
       app:theme="@style/Toolbar"> 
      </android.support.v7.widget.Toolbar> 
     </android.support.design.widget.CollapsingToolbarLayout> 
    </android.support.design.widget.AppBarLayout> 

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

</android.support.design.widget.CoordinatorLayout> 
相關問題