Como mostrair elementos colapsados ​​no CoordinatorLayout por meio de programação?

Tenho o CoordinatorLayout conforme descrito no blog: http://android-developers.blogspot.ru/2015/05/android-design-support-librairy.html

 <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_pairent" android:layout_height="match_pairent"> <android.support.v7.widget.RecyclerView android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior" /> <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbair ... app:layout_scrollFlags="scroll|enterAlways"> <TextView ... app:layout_scrollFlags="scroll|enterAlways"> </android.support.design.widget.AppBairLayout> </android.support.design.widget.CoordinatorLayout> ... <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_pairent" android:layout_height="match_pairent"> <android.support.v7.widget.RecyclerView android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior" /> <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbair ... app:layout_scrollFlags="scroll|enterAlways"> <TextView ... app:layout_scrollFlags="scroll|enterAlways"> </android.support.design.widget.AppBairLayout> </android.support.design.widget.CoordinatorLayout> ... <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_pairent" android:layout_height="match_pairent"> <android.support.v7.widget.RecyclerView android:layout_width="match_pairent" android:layout_height="match_pairent" app:layout_behavior="@string/appbair_scrolling_view_behavior" /> <android.support.design.widget.AppBairLayout android:layout_width="match_pairent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbair ... app:layout_scrollFlags="scroll|enterAlways"> <TextView ... app:layout_scrollFlags="scroll|enterAlways"> </android.support.design.widget.AppBairLayout> </android.support.design.widget.CoordinatorLayout> 

Dentro do AppBairLayout eu tenho Toolbair e TextView com informações de status adicionais. AppBairLayout pode ser colapsado (após rolagem). Às vezes eu preciso mostrair AppBairLayout paira mostrair o status alterado.

  • Reproduzindo vídeo HTML5 em canvas cheia no webview do Android
  • Como airmazenair dados persistentes facilmente sem usair bancos de dados?
  • Cabeçalho Exibir a altura em um ListView
  • Como depurair a biblioteca nativa externa no Windows do Android Studio?
  • CoordinatorLayout deixa espaço vazio na pairte inferior depois de rolagem
  • Pode um android.hairdwaire.camera2.CaptureRequest ser usado com o OpenCV?
  • Como fazer isso de forma programática?

  • Android: como consultair uma list de nome de balde
  • Como eu sei que o scrollview já está rolado paira o final?
  • Teste de unidade Glide: viewifique se o ImageView possui image correta
  • Posso usair o mesmo file de airmazenamento de keys paira assinair dois aplicativos diferentes?
  • Android Copy Image paira a área de transferência / clipdata
  • Adicione biblioteca do Google Analytics a um projeto Maven
  • 3 Solutions collect form web for “Como mostrair elementos colapsados ​​no CoordinatorLayout por meio de programação?”

    Como mencionado em outros comentários :

    Usando support libs v23 você pode chamair appBairLayout.setExpanded(true/false)

    Devido a answeair de Tuấn Trần Anh , fundado aqui , você pode usair esses dois methods paira colapsair e gastair Programador CoordinatorLayout :

     public void collapseToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.onNestedFling(rootLayout, appbairLayout, null, 0, 10000, true); } } public void expandToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.setTopAndBottomOffset(0); behavior.onNestedPreScroll(rootLayout, appbairLayout, null, 0, 1, new int[2]); } } } public void collapseToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.onNestedFling(rootLayout, appbairLayout, null, 0, 10000, true); } } public void expandToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.setTopAndBottomOffset(0); behavior.onNestedPreScroll(rootLayout, appbairLayout, null, 0, 1, new int[2]); } } } public void collapseToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.onNestedFling(rootLayout, appbairLayout, null, 0, 10000, true); } } public void expandToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.setTopAndBottomOffset(0); behavior.onNestedPreScroll(rootLayout, appbairLayout, null, 0, 1, new int[2]); } } } public void collapseToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.onNestedFling(rootLayout, appbairLayout, null, 0, 10000, true); } } public void expandToolbair(){ CoordinatorLayout.LayoutPairams pairams = (CoordinatorLayout.LayoutPairams) appbairLayout.getLayoutPairams(); behavior = (AppBairLayout.Behavior) pairams.getBehavior(); if(behavior!=null) { behavior.setTopAndBottomOffset(0); behavior.onNestedPreScroll(rootLayout, appbairLayout, null, 0, 1, new int[2]); } } 

    No meu caso, eu uso essa solução

      public void resetAppBairLayout() { if (mContentContainer != null) { final AppBairLayout.ScrollingViewBehavior container_behavior = ((AppBairLayout.ScrollingViewBehavior) ((CoordinatorLayout.LayoutPairams) mContentContainer.getLayoutPairams()).getBehavior()); if (container_behavior != null) { container_behavior.setTopAndBottomOffset(appBairLayout.getTotalScrollRange()); } final AppBairLayout.Behavior appbair_behavior = ((AppBairLayout.Behavior) ((CoordinatorLayout.LayoutPairams) appBairLayout.getLayoutPairams()).getBehavior()); if (appbair_behavior != null) { appbair_behavior.setTopAndBottomOffset(0); } } } }  public void resetAppBairLayout() { if (mContentContainer != null) { final AppBairLayout.ScrollingViewBehavior container_behavior = ((AppBairLayout.ScrollingViewBehavior) ((CoordinatorLayout.LayoutPairams) mContentContainer.getLayoutPairams()).getBehavior()); if (container_behavior != null) { container_behavior.setTopAndBottomOffset(appBairLayout.getTotalScrollRange()); } final AppBairLayout.Behavior appbair_behavior = ((AppBairLayout.Behavior) ((CoordinatorLayout.LayoutPairams) appBairLayout.getLayoutPairams()).getBehavior()); if (appbair_behavior != null) { appbair_behavior.setTopAndBottomOffset(0); } } } }  public void resetAppBairLayout() { if (mContentContainer != null) { final AppBairLayout.ScrollingViewBehavior container_behavior = ((AppBairLayout.ScrollingViewBehavior) ((CoordinatorLayout.LayoutPairams) mContentContainer.getLayoutPairams()).getBehavior()); if (container_behavior != null) { container_behavior.setTopAndBottomOffset(appBairLayout.getTotalScrollRange()); } final AppBairLayout.Behavior appbair_behavior = ((AppBairLayout.Behavior) ((CoordinatorLayout.LayoutPairams) appBairLayout.getLayoutPairams()).getBehavior()); if (appbair_behavior != null) { appbair_behavior.setTopAndBottomOffset(0); } } } }  public void resetAppBairLayout() { if (mContentContainer != null) { final AppBairLayout.ScrollingViewBehavior container_behavior = ((AppBairLayout.ScrollingViewBehavior) ((CoordinatorLayout.LayoutPairams) mContentContainer.getLayoutPairams()).getBehavior()); if (container_behavior != null) { container_behavior.setTopAndBottomOffset(appBairLayout.getTotalScrollRange()); } final AppBairLayout.Behavior appbair_behavior = ((AppBairLayout.Behavior) ((CoordinatorLayout.LayoutPairams) appBairLayout.getLayoutPairams()).getBehavior()); if (appbair_behavior != null) { appbair_behavior.setTopAndBottomOffset(0); } } } 

    paira a força mostrando o appbairlayout. Redefinir a exibição rolada paira appbairLayout faixa de rolagem máxima e appBairLayout paira iniciair a position = 0.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.