Why android popupwindow showAsDropDown offsetx is not effective? -


popupwindow.showasdropdown(morebutton, xoffset, yoffset); 

no matter value of xoffset, popup on right side of screen display

final popupwindow popupwindow = new popupwindow(dashboardactivity.applicationcontext);                         layoutinflater inflater = (layoutinflater) dashboardactivity.applicationcontext.getsystemservice(                                 context.layout_inflater_service); popupwindow.setfocusable(true);                         popupwindow.setwidth(windowmanager.layoutparams.wrap_content);                         popupwindow.setheight(windowmanager.layoutparams.wrap_content);                         popupwindow.setcontentview(view);                         popupwindow.setbackgrounddrawable(new colordrawable(                                 android.graphics.color.transparent)); popupwindow.showasdropdown(morebutton, **-220**, -40); 

no matter set value offsetx, on right side of screen display

popupwindow tries align contentview anchor's gravity.top | gravity.start (top left corner) default. if there no space left contentview gets offset fit on screen, why stays on right side.

the following xoffset align contentview @ anchor's top right corner:

view.measure(view.measurespec.unspecified, view.measurespec.unspecified); int xoffset = -(view.getmeasuredwidth() - morebutton.getwidth());  popupwindow.showasdropdown(morebutton, xoffset, 0); 

you might want like:

popupwindow.showasdropdown(morebutton, xoffset - 220, -40); 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -