安卓通知栏和标题栏的大小? [英] Size of android notification bar and title bar?

查看:102
本文介绍了安卓通知栏和标题栏的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法获得通知栏和标题栏的机器人的大小?目前,我得到的显示宽度和高度与:

Is there a way to obtain the size of the notification bar and title bar in android? At the moment I obtain display width and height with:

Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();

之后,我想减去棒的大小,这样我可以伸展的视频没有松动的比例。目前,我隐藏了吧,因为我看不到更好的办法。

After that I want to subtract the sizes of the bars so that I can stretch a video without loosing ratio. Currently I hide the bars because I can't see a better way.

推荐答案

也许这是一个有用的方法:参照的图标设计准则有根据屏幕密度状态(通知)栏只有三个不同的高度:

Maybe this is a helpful approach: Referring to the Icon Design Guidelines there are only three different heights for the status (notification) bar depending on the screen density:

  • 24PX为LDPI
  • 32PX为MDPI
  • 48像素的华电国际

因此​​,如果您检索设备的使用 densityDpi 中的 DisplayMetrics 你知道要减去其值

So if you retrieve the screen density of the device using densityDpi of DisplayMetrics you know which value to subtract

所以它可以看看这样的事情:

so it could look something like that:

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int myHeight = 0;

    switch (metrics.densityDpi) {
        case DisplayMetrics.DENSITY_HIGH:
            Log.i("display", "high");
            myHeight = display.getHeight() - 48;
            break;
        case DisplayMetrics.DENSITY_MEDIUM:
            Log.i("display", "medium/default");
            myHeight = display.getHeight() - 32;
            break;
        case DisplayMetrics.DENSITY_LOW:
            Log.i("display", "low");
            myHeight = display.getHeight() - 24;
            break;
        default:
            Log.i("display", "Unknown density");

这篇关于安卓通知栏和标题栏的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆