Android Gets the height of the system top status bar (StatusBar) and the bottom toolbar (navigationbar)

Source: Internet
Author: User

Android Some devices have up to two bar, we can get information about these bars. Put the code that gets the height below. Code comments and other methods are free to put.

Original address http://www.cnblogs.com/rossoneri/p/4142962.html

Get Top status bar height

Private int getstatusbarheight () {    = mactivity.getresources ();     int resourceId = resources.getidentifier ("Status_bar_height", "Dimen", "Android");     int height = resources.getdimensionpixelsize (resourceId);    LOG.V ("dBW", "Status Height:" + height);     return height;}

Get bottom navigation bar height

Private int getnavigationbarheight () {    = mactivity.getresources ();     int resourceId = resources.getidentifier ("Navigation_bar_height", "Dimen", "Android");     int height = resources.getdimensionpixelsize (resourceId);    LOG.V ("dBW", "Navi Height:" + height);     return height;}

Android Gets the height of the system top status bar (StatusBar) and the bottom toolbar (navigationbar)

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.