屏幕尺寸蜂窝菜单的android蜂窝、菜单、屏幕尺寸、android

2023-09-08 09:18:55 作者:Anxious 焦灼

你好我想哟得到屏幕的屏幕尺寸减去底部菜单栏。

Hi I am trying yo get the screen size of screen minus the menu bar at the bottom.

我知道我可以根据设备的分辨率只是减去一个常数,但它是一个超级丑陋的黑客。我相信谷歌的人都不会傻到忘了给用户一个函数来获取底部菜单栏的高度,这样我就可以在全屏幕大小减去它

I know I could just subtract a constant number according to the resolution of the device but it is a super ugly hack. I am sure google people are not dumb enough to forget to give the user a function to get the height of the bottom menu bar so I can subtract it from the full screen size

这是一个类似的帖子。 Size安卓通知栏和标题栏的?

This is a similar post. Size of android notification bar and title bar?

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

what_i_need =metrics.heightPixels-buttomMenuHeight();

我需要buttomMenuHeight();

I need buttomMenuHeight();

我找不到它的API中。我真的不关心落后的可比性,在这一点上

i could not find it in the API. I don't really care about the backward comparability at this point

感谢

推荐答案

为什么不使用活动的顶级观的高度?例如如果你的活动包含一个全高的LinearLayout,利用其高度,所以你不必知道菜单的高度,或者noticiation杆高度。

Why not use the height of the activity's top-level View? e.g. if your activity contains a full-height LinearLayout, use its height, so you don't have to know the menu height, or noticiation bar height.

我觉得你踩一条危险的道路做这种计算的,因为你不知道什么为Android未来的布局可能是,也可能有什么不同谷歌电视,或者其他的。

I think you're treading a dangerous road doing this kind of calculation, as you don't know what the future layouts for Android might be, or how they might differ on Google TV, or whatever.

 
精彩推荐
图片推荐