How to realize this custom popup menu with Material Design Android? -
i want realize custom popup menu twitter in android example item , picture don't know what's component used that.
in material design website, google present this solution. think, there native solution achieve this.
i tried popup menu, can't find how customize layout of view that.
you can use listpopupwindow, submitting custom adapter, through can control layout of every single row of listpopupwindow
. normal popupwindow
have provide anchor view , additionally have call setcontentwidth
on instance of listpopupwindow
, sets width of popup window size of content. small price have pay, small dataset not big deal. have utility method retrieve max width of row:
public int measurecontentwidth(listadapter adapter) { int maxwidth = 0; int count = adapter.getcount(); final int widthmeasurespec = measurespec.makemeasurespec(0, measurespec.unspecified); final int heightmeasurespec = measurespec.makemeasurespec(0, measurespec.unspecified); view itemview = null; (int = 0; < count; i++) { itemview = adapter.getview(i, itemview, this); itemview.measure(widthmeasurespec, heightmeasurespec); maxwidth = math.max(maxwidth, itemview.getmeasuredwidth()); } return maxwidth; }
Comments
Post a Comment