【发布时间】:2011-07-01 02:18:17
【问题描述】:
【问题讨论】:
标签: android
【问题讨论】:
标签: android
if(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
{
// code to do for Portrait Mode
} else {
// code to do for Landscape Mode
}
【讨论】:
使用 getResources().getConfiguration().orientation。
http://developer.android.com/reference/android/content/res/Configuration.html#orientation
【讨论】:
getResources().getConfiguration().orientation
或用于收听定向事件:http://android-developers.blogspot.in/2010/09/one-screen-turn-deserves-another.html
或使用OrientationEventListener
【讨论】:
您可以检测当前的宽度和高度。如果高度大于宽度,则屏幕为纵向模式,否则为横向模式。
【讨论】: