into the internet industry for a few days, from the mobile phone industry to the Internet industry is also slowly adapting to: the use of IDE tools (previously developed in the Ubuntu Command line), version management tools, code architecture, etc. these need to be re-adapted. Fortunately, I still have some foundation, so the adaptation is also fast ^_^. Start sharing today with a small problem you met yesterday.
First
, the bottom navigator overlaps with the OK button when you use Popupwindow to display the menu.
The idea of solving this problem is to determine if the bottom navigator is open, calculate the height of the navigator if open, and then make the Y coordinate the height of the displacement navigator when the popupwindow.showatlocation is called.
The specific method can see the following two methods: respectively, is to determine the height of navigator and navigator whether the display---mcoy is my english name ^_^
/**
* Add by Mcoy for bugid=427
* @return The height of the bottom status bar
*/
private int getnavigationbarheight () {
if (!hassoftkeys ((WindowManager) Context.getsystemservice (Context.window_service))) {
return 0;
}
Resources resources = Context.getresources ();
int resourceId = Resources.getidentifier ("Navigation_bar_height", "Dimen", "Android");
int height = resources.getdimensionpixelsize (resourceId);
LOG.E ("Mcoy", "the height is" + height);
return height;
}
/**
* Add by Mcoy for bugid=427, determine if the bottom navigator has been shown
* @param WindowManager
* @return
*/
Private Boolean Hassoftkeys (WindowManager windowmanager) {
Display d = windowmanager.getdefaultdisplay ();
Displaymetrics realdisplaymetrics = new Displaymetrics ();
D.getrealmetrics (Realdisplaymetrics);
int realheight = Realdisplaymetrics.heightpixels;
int realwidth = Realdisplaymetrics.widthpixels;
Displaymetrics displaymetrics = new Displaymetrics ();
D.getmetrics (Displaymetrics);
int displayheight = Displaymetrics.heightpixels;
int displaywidth = Displaymetrics.widthpixels;
Return (Realwidth-displaywidth) > 0 | | (realheight-displayheight) > 0;
}
The height of Android navigator is calculated and judged to be displayed