Sig*_*ggy 14
您可以像这样获取屏幕方向(例如在您的onResume()方法中):
private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 3;
private static final int ORIENTATION_270 = 1;
Display display = ((WindowManager)
getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int screenOrientation = display.getRotation();
switch (screenOrientation)
{
default:
case ORIENTATION_0: // Portrait
// do smth.
break;
case ORIENTATION_90: // Landscape right
// do smth.
break;
case ORIENTATION_270: // Landscape left
// do smth.
break;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14866 次 |
| 最近记录: |