`
dengyin2000
  • 浏览: 1208258 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

获取status bar的高度

 
阅读更多
    public static int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }


还能获取些什么属性的值呢? 请看{sdk.home}\platforms\android-21\data\res\values\dimens.xml

    <!-- Height of the status bar -->
    <dimen name="status_bar_height">25dip</dimen>
    <!-- Height of the bottom navigation / system bar. -->
    <dimen name="navigation_bar_height">48dp</dimen>
    <!-- Height of the bottom navigation bar in portrait; often the same as @dimen/navigation_bar_height -->
    <dimen name="navigation_bar_height_landscape">48dp</dimen>
    <!-- Width of the navigation bar when it is placed vertically on the screen -->
    <dimen name="navigation_bar_width">42dp</dimen>
    <!-- Height of notification icons in the status bar -->
    <dimen name="status_bar_icon_size">24dip</dimen>
    <!-- Size of the giant number (unread count) in the notifications -->
    <dimen name="status_bar_content_number_size">48sp</dimen>
    <!-- Margin at the edge of the screen to ignore touch events for in the windowshade. -->
    <dimen name="status_bar_edge_ignore">5dp</dimen>


Reference: http://mrtn.me/blog/2012/03/17/get-the-height-of-the-status-bar-in-android/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics