The height of Android navigator is calculated and judged whether it is displayed

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.