seba123neo seba123neo - 8 months ago 649
Android Question

Toolbar inside CardView to create a popup menu (overflow icon)

I have a list that looks like google play in a recyclerview with cardview, and works perfect.

I need to add a popup menu (with overflow icon), like this:

which is the best way to do this ?

I researched and found that there are 2 options:

1 - with a toolbar inside the cardview layout. is there a performanece problem with this solution ?

2 - with a imagebutton or imageview with a icon of the overflow,
that when you click the menu is created.

I need a solution to be compatible with >= API 10



It depends by your layout.

If you would like a layout like this, with a Toolbar you can achieve it more easily. enter image description here

Somenthing like



        <Toolbar  android:id="@+id/card_toolbar" />




toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener(){..});

If you would like only a popup is more simple to use an image. Somenthing like:

PopupMenu popup = new PopupMenu(getContext(), mImageButton);
MenuInflater inflater = popup.getMenuInflater();