Toolbar becomes invisible or disappears when pressed back. This situation occurs only if the panel is minimized .
- I have a RecyclerView on fragment
- When I view recyclers, the toolbar collapses
- If I enter the next operation caused by some of the recycler itens, and then click the back button, the toolbar will disappear.
- If I scroll through the recyclers, it still crashes, but the toolbar is not there, just a vertical space on which there is nothing.
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">
<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" />
<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" />
<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 a layout on a fragment
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
fragmentView = inflater.inflate(R.layout.tasklist_fragment, container, false);
Some possible problems
W/View﹕ requestLayout() improperly called by android.support.v7.widget.Toolbar{335f934 V.E..... ......ID 0,0-1080,168
W/View﹕ requestLayout() improperly called by android.support.design.widget.CollapsingToolbarLayout{3c2cf991 V.ED.... ......I. 0,0-1080,420
source
share