在 Android 手机上检查方向 [英] Check orientation on Android phone
本文介绍了在 Android 手机上检查方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何查看安卓手机是横屏还是竖屏?
How can I check if the Android phone is in Landscape or Portrait?
推荐答案
当前配置(用于确定要检索的资源)可从 Resources 的 Configuration
对象获得:
The current configuration, as used to determine which resources to retrieve, is available from the Resources' Configuration
object:
getResources().getConfiguration().orientation;
您可以通过查看其值来检查方向:
You can check for orientation by looking at its value:
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
// In landscape
} else {
// In portrait
}
更多信息可以在 Android 开发者.
这篇关于在 Android 手机上检查方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文