gpt4 book ai didi

android - Android 平板电脑上的系统栏大小

转载 作者:太空狗 更新时间:2023-10-29 15:39:16 26 4
gpt4 key购买 nike

我遇到了一个问题,我需要 android 平板电脑系统栏的高度。这与 here 上的问题相同,但我不能使用这个答案,因为它给我的尺寸与 DisplayMetrics 的尺寸相同。在这两种方式中,我都得到了已经在其中计算出的这个条的分辨率。 (这个问题没有出现在我的智能手机上,只出现在我的平板电脑上)。

最佳答案

// status bar (at the top of the screen on a Nexus device) 
public static int getStatusBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}

// navigation bar (at the bottom of the screen on a Nexus device)
public static int getNavigationBarHeight(Context context) {
Resources resources = context.getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
return 0;
}

关于android - Android 平板电脑上的系统栏大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10165563/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com