0
0

【Android】画面回転した時に処理を入れたい【Kotlin】

Posted at

実践

AndroidManifestに以下を記載します。

android:configChanges="orientation|screenSize"

また、以下をActivityに記載します。

override fun onConfigurationChanged(newConfig: Configuration) {
        // ここに回転した時の処理
 }

onConfigurationChanged

onConfigurationChanged() メソッドは、デバイス構成を指定する Configuration オブジェクトを受け取ります。アクティビティを再起動することなく UI の要素を再設定できるようになります。

Configurationオブジェクトとは、すべてのデバイス構成情報を記述します。
具体的には入力モード、画面サイズ、画面の向きなどに影響を与えるオブジェクトです。

参考

0
0
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
0
0