zoukankan      html  css  js  c++  java
  • Android获取状态栏高度

        private int getStatusBarHeight() {

            int statusBarHeight = 0;

                try {

                    Class<?> c = Class.forName("com.android.internal.R$dimen");

                    Object o = c.newInstance();

                    Field field = c.getField("status_bar_height");

                    int x = (Integer) field.get(o);

                    statusBarHeight = getResources().getDimensionPixelSize(x);

                } catch (Exception e) {

                    e.printStackTrace();

                    Rect frame = new Rect();

                    getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);

                    statusBarHeight = frame.top;

                }

                return statusBarHeight;

        }

  • 相关阅读:
    webstorm
    呐,这是某蒟蒻幼稚的博客 ~~Welcome
    CSP-S 2021 补题记录
    CSP-S 2021 游记
    Tarjan 算法小结
    FHQ Treap 浅析
    2048游戏 (C++ Windows)
    线段树 算法分析
    树状数组 算法分析
    数学期望(ξ) 浅析
  • 原文地址:https://www.cnblogs.com/yiludugufei/p/4444428.html
Copyright © 2011-2022 走看看