LoginSignup
2
4

More than 5 years have passed since last update.

Androidで画面回転時にActivityを維持する方法

Last updated at Posted at 2016-01-23

説明

AndroidのActivityは、端末回転時に縦レイアウト、横レイアウトの切り替えをするために、写真投稿アプリなどで画像が消えてしまう場合があります。
端末の状態が変更された場合のハンドリングを設定する「android:configChanges」属性を使うとこの問題を簡単に回避できます。

手順

AndroidManifest.xmlで画面回転時の処理を設定したいactivityタグに「android:configChanges="orientation|screenSize"」を追記するだけです。

    <activity android:name=".PostActivity"
        android:configChanges="orientation|screenSize"></activity>

参考URL

http://kobegdg.blogspot.jp/2012/11/activity.html
http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4