在Android手机上检查方向(Check orientation on Android phone)
如何检查Android手机是横向还是纵向?
How can I check if the Android phone is in Landscape or Portrait?
最满意答案
当前配置,用于确定哪些资源可以从资源配置对象中获取,如下所示:
getResources().getConfiguration().orientationhttp://developer.android.com/reference/android/content/res/Configuration.html#orientation
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 }More information can be found in the Android Developer.
更多推荐
发布评论