android - Toolbar disappear when backPressed if collapsed -


my toolbar becoming invisible or disappearing when backpressed. situation occur if toolbar collapsed.

  1. i have recyclerview on fragment
  2. when scroll recycler toolbar collapses
  3. if enter on next activity, called of recycler itens , press button, toolbar disappear.
  4. if scroll recycler collapsing still occurs, toolbar isn't there, vertical space nothing on it.

fragment layout

<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true">    <android.support.design.widget.appbarlayout     android:id="@+id/appbar"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:minheight="?attr/actionbarsize"     android:theme="@style/themeoverlay.appcompat.dark.actionbar"     android:fitssystemwindows="true">           <!--toolbar-->         <android.support.v7.widget.toolbar             style="@style/mytoolbar_details"             android:id="@+id/toolbar"             app:layout_scrollflags="scroll|enteralways"             app:popuptheme="@style/themeoverlay.appcompat.light"             android:background="@color/theme_primary"             app:layout_collapsemode="none" />      <!--toolbar sort-->     <android.support.v7.widget.toolbar         style="@style/mytoolbar_details"         android:id="@+id/toolbar_sort"         android:title="toolbar"         app:popuptheme="@style/themeoverlay.appcompat.light"         android:background="@color/theme_primary_dark"         android:visibility="gone"         app:layout_collapsemode="pin" />     </android.support.design.widget.appbarlayout>    <android.support.v7.widget.recyclerview     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@+id/fragment_tasklist_recyclerview"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior" />    <!--add fragment container-->   <relativelayout     android:id="@+id/add_container"     android:layout_width="match_parent"     android:fitssystemwindows="true"     android:layout_height="match_parent" /> </android.support.design.widget.coordinatorlayout> 

calling layout on fragment

@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     fragmentview    = inflater.inflate(r.layout.tasklist_fragment, container, false); 

some probable issues

w/view﹕ requestlayout() improperly called android.support.v7.widget.toolbar{335f934 v.e..... ......id 0,0-1080,168 #7f0d009c app:id/toolbar} during layout: running second layout pass  w/view﹕ requestlayout() improperly called android.support.design.widget.collapsingtoolbarlayout{3c2cf991 v.ed.... ......i. 0,0-1080,420 #7f0d009a app:id/collapsing_toolbar} during second layout pass: posting in next frame 

turns out code ok. problem caused bug on appcompat lib. updated support library version 22.2.1 , issue disappeared.

compile "com.android.support:appcompat-v7:22.2.1" compile "com.android.support:support-annotations:22.2.1" compile "com.android.support:design:22.2.1" compile 'com.android.support:recyclerview-v7:22.2.1' compile 'com.android.support:cardview-v7:22.2.1' 

Comments