检测的Android导航栏方向 [英] Detect Android Navigation Bar orientation
本文介绍了检测的Android导航栏方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法知道这个导航栏将显示为景观:
Is there a way to know where this Navigation Bar will be displayed for landscape :
- 在Nexus7是在底部
- 在一个承上启下五是在正确的。
感谢
推荐答案
通过使用的装饰视图结合当前 DisplayMetrics 你可以找到出在哪一侧的导航栏的位置。
By using the properties of the decor view in combination with the current DisplayMetrics you can find out on which side the navigation bar is positioned.
// retrieve the position of the DecorView
Rect visibleFrame = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(visibleFrame);
DisplayMetrics dm = getResources().getDisplayMetrics();
// check if the DecorView takes the whole screen vertically or horizontally
boolean isRightOfContent = dm.heightPixels == visibleFrame.bottom;
boolean isBelowContent = dm.widthPixels == visibleFrame.right;
这篇关于检测的Android导航栏方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文