Menu Options Not Displaying on the Collapsing Toolbar

I am trying to implement a Collapsing toolbar layout with menu options, but whenever I set the image source in the code below, the image spans the menu and the back button. There are options, because I can click on them, they are simply hidden from the image. Does anyone know how to fix this?

XML layout

<android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:toolbarId="@+id/toolbar"> <android.support.v7.widget.Toolbar android:id="@+id/detail_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:fitsSystemWindows="true"/> <ImageView android:src="@drawable/background" app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="centerCrop" app:layout_collapseMode="parallax" android:minHeight="100dp" android:fitsSystemWindows="true"/> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> 
+5
source share
3 answers

try the following:

 <?xml version="1.0" encoding="utf-8"?> <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/coordinator" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" > <android.support.design.widget.AppBarLayout android:id="@+id/app_bar" android:layout_width="match_parent" android:layout_height="@dimen/app_bar_height" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" > <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/toolbar_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed" android:fitsSystemWindows="true" app:contentScrim="?attr/colorPrimary" app:toolbarId="@+id/toolbar" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_collapseMode="parallax" android:background="@drawable/background" android:fitsSystemWindows="true" android:minHeight="100dp" android:scaleType="centerCrop" /> <android.support.v7.widget.Toolbar android:id="@+id/detail_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:layout_collapseMode="pin" android:fitsSystemWindows="true" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> </android.support.design.widget.CoordinatorLayout> 

if any problems leave a comment

Good luck

+5
source

From my own experience, this tells me about this, probably you forgot to add the following lines to the action:

Toolbar toolbar = (Toolbar) findViewById (R.id.toolbar);

setSupportActionBar (toolbar);

+3
source

Try adding collapseMode attributes to your toolbar ... like this. He clamps the toolbar.

 <android.support.v7.widget.Toolbar app:layout_collapseMode="pin" /> 
+1
source

Source: https://habr.com/ru/post/1237522/


All Articles