1

Ich habe ein reduzierendes Symbolleistenlayout. Ich habe ein Diagramm darauf gezeigt. Wenn also im Diagramm keine Elemente angezeigt werden sollen, muss das minimierte Symbolleistenlayout als ausgeblendet oder ausgeblendet oder geschlossen angezeigt werden. Nur die Symbolleiste und der Titel sollten angezeigt werden und nicht die Grafik. HierSo zeigen Sie die minimierende Symbolleiste als minimiert an, ohne zu scrollen android

ist der Ansicht:

enter image description here

ich nur die Symbolleiste angezeigt werden soll, wo ich ein Menü-Icon auf der linken Seite haben.

Layout-Code:

<android.support.design.widget.CoordinatorLayout 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:layout_gravity="center" 
    tools:context="com.example.siddhi.googletaskmanager" 
    xmlns:fab="http://schemas.android.com/apk/res-auto" 
    android:fitsSystemWindows="true" 
    android:id="@+id/parentPanel" 
    android:background="@color/background"> 


    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="220dp" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:id="@+id/appbar" 
     android:fitsSystemWindows="true"> 


     <android.support.design.widget.CollapsingToolbarLayout 
      android:id="@+id/collapsing_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:titleEnabled="false" 
      app:contentScrim="?attr/colorPrimary" 
      android:fitsSystemWindows="true" 
      app:expandedTitleTextAppearance="@style/expandedappbar" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

       <com.github.mikephil.charting.charts.HorizontalBarChart 
        android:id="@+id/chart" 
        android:layout_width="match_parent" 
        android:layout_height="100dp" 
        android:layout_below="@+id/toolbar" 
        app:layout_collapseMode="parallax" 
        android:layout_gravity="bottom" 
        android:layout_marginBottom="40dp"/> 


      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       app:layout_collapseMode="pin" /> 

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

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


    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" 
     android:paddingTop="10dp" /> 



     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 

      android:weightSum="1"> 


      <com.github.clans.fab.FloatingActionMenu 
       android:id="@+id/menu1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingRight="10dp" 
       android:paddingBottom="10dp" 
       android:paddingLeft="10dp" 
       app:menu_colorNormal="@color/colorAccent" 
       app:menu_colorPressed="@color/colorAccent" 
       fab:menu_icon="@drawable/ic_more_horiz_white_24dp" 
       fab:menu_labels_ellipsize="end" 
       fab:menu_labels_singleLine="true" 
       fab:menu_backgroundColor="@color/colorPrimary" 
       android:layout_alignParentTop="true" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentStart="true"> 



       <com.github.clans.fab.FloatingActionButton 
        android:id="@+id/fab1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_list_white_24dp" 
        fab:fab_size="mini" 
        fab:fab_label="List 1" 
        app:fab_colorPressed="@color/colorAccent" 
        app:fab_colorNormal="@color/colorAccent"/> 

       <com.github.clans.fab.FloatingActionButton 
        android:id="@+id/fab2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_list_white_24dp" 
        fab:fab_size="mini" 
        fab:fab_label="List 2" 
        app:fab_colorPressed="@color/colorAccent" 
        app:fab_colorNormal="@color/colorAccent"/> 

       <com.github.clans.fab.FloatingActionButton 
        android:id="@+id/fab3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_list_white_24dp" 
        fab:fab_size="mini" 
        fab:fab_label="List 3" 
        app:fab_colorPressed="@color/colorAccent" 
        app:fab_colorNormal="@color/colorAccent"/> 

      </com.github.clans.fab.FloatingActionMenu> 

      <com.github.clans.fab.FloatingActionButton 
       android:id="@+id/fab" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_add_white_24dp" 
       fab:fab_size="normal" 
       app:fab_colorPressed="@color/colorAccent" 
       app:fab_colorNormal="@color/colorAccent" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentEnd="true" 
       android:layout_marginRight="80dp" 
       android:layout_marginEnd="80dp" 
       android:layout_marginBottom="10dp" /> 


     </RelativeLayout> 

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

EDIT:

Mein aktueller Code ist dies:

if(mItems.size() == 0) { 
        mBarChart.setVisibility(View.INVISIBLE); 
        appBarLayout.setExpanded(false,false); 
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams)appBarLayout.getLayoutParams(); 
        // lp.height = (int) getResources().getDimension(R.dimen.toolbar_height); 
        lp.height = (int) (android.R.attr.actionBarSize); 

       } 
       else 
       { 
        appBarLayout.setExpanded(true); 
        CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams)appBarLayout.getLayoutParams(); 
        lp.height = (int) getResources().getDimension(R.dimen.appbar_height); 
        mBarChart.setVisibility(View.VISIBLE); 
       } 

Dimension:

<dimen name="toolbar_height">128dp</dimen> 
<dimen name="appbar_height">200dp</dimen> 

Wie kann ich das erreichen? Vielen Dank ..

Antwort

2

Sie können dies programmatisch mit appBarLayout.setExpanded(true/false) tun.

if(yourGraphIsEmpty){ 
    appBarLayout.setExpanded(false); 
}else{ 
    appBarLayout.setExpanded(true); 
} 

Das Kernproblem ist, dass es keine CollapsingToolbarLayout.lock (ist); Verfahren bis jetzt (v23.2.1 von Support Design)

This post ist eine Komplettlösung, die wirklich gut das funktioniert

+0

gut funktioniert .. aber ich es später erweitern kann. Ich sollte die Appbar nicht erweitern können. Wie macht man das? @David Seroussi – Sid

+0

Wenn ich Scroll-Flag als 0 setzen, wird auch das Diagramm angezeigt. Ich kann die Symbolleiste nicht ausblenden. @David Seroussi – Sid

+0

Bearbeitet wieder, verknüpft mit einer anderen Antwort –

Verwandte Themen