1

CollapsingToolbarLayoutで私のアプリケーションでCollapsingToolbarLayoutを使用しています。ツールバーとx軸とy軸を描くMPAndroidチャートを使用しているグラフがあります...とにかく、問題はツールバーがチャート上で、我々は、チャート(アクションバーの正確大きさ)の上部を見ることができない、どのように私はツールバーの下に私のチャートビューを置くことができ、私のコードです: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> 
関連する問題