Android Lollipop, add popup menu from toolbar title

I don’t see how to add a pop-up menu from the header, as shown in many material design examples. Any help would be greatly appreciated.

Toolbar Popup From Title

+44
android android-5.0-lollipop android-toolbar
Oct. 22 '14 at 15:14
source share
1 answer

You will need to add Spinner to the toolbar:

<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_height="?attr/actionBarSize" android:layout_width="match_parent" android:background="?attr/colorPrimary"> <Spinner android:id="@+id/spinner_nav" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </android.support.v7.widget.Toolbar> 

Then you need to disable the default header:

 Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); 

You can then get and configure Spinner as needed in your Activity / Fragment.

+94
Oct 22 '14 at 15:50
source share



All Articles