0

我已经锁定了我的显示方向

 this.setRequestedOrientation(
            ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

在我的onCreate()方法中,这当然可以正常工作。现在我想处理我的显示方向的变化。我想以与在 android 相机中实现的方式相同的方式旋转 ImageView。有任何想法吗?多谢

4

1 回答 1

0

在您的清单中,您可以将此属性添加到您要检查的活动中:

<activity android:name=".MyActivity"
      android:configChanges="orientation"
      android:label="@string/app_name" />

而您的活动代码只是覆盖此方法:

@Override
public void onConfigurationChanged(Configuration newConfig) {
     super.onConfigurationChanged(newConfig);

     // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
        Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
    }
}

以供参考:

http://developer.android.com/guide/topics/resources/runtime-changes.html

于 2012-07-03T10:55:20.027 回答