Search code examples
androidcardslib

How to add overflow icon items in a card in Android


Hi I am trying to create a layout like this using support library https://developer.android.com/reference/android/support/v7/widget/CardView.html but i didn't found a way to add overflow icon in a card.

I don't want to use this library https://github.com/gabrielemariotti/cardslib/blob/master/doc/CARDGRID.md. I want to do same using support library that Google introduced recently.

Isn't there is way to achieve using support library or I have to use gabrielemariotti library to add overflow items in a card view.

enter image description here

Update

Guys I have edited question now it is more clear what i want.


Solution

  • First of all you shouldn't use this lib only to achieve an overflow menu inside a card.

    Said that,the CardView in support Library is a FrameLayout with any model behind. The best way to achieve it, now is to use the new Toolbar inside the CardView layout.

    Also you can add a ImageView inside the CardView layout and do something like this:

    PopupMenu popup = new PopupMenu(getContext(), mImageButton);
    MenuInflater inflater = popup.getMenuInflater();
    inflater.inflate(R.menu.your_menu, popup.getMenu());
    

    Finally (but it is not so important) if it isn't enough, the new cardslib (coming soon) will use the CardView in support library.