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 に答える