自分で縦横レイアウトを切り替えるので Manifest に設定を追加 <activity android:name=".MainActivity" android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> ... </activity> 縦画面用のレイアウトと、横画面用のレイアウトを用意する。 例としてここでは縦画面では上部に 16:9 で配置し、横画面では全画面に配置している。 縦画面用 res/layout/activity_main_port.xml <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.an
![ConstraintSet を使って Activity を再生成せずにレイアウトを切り替える](https://cdn-ak-scissors.b.st-hatena.com/image/square/7a56e47cb2df2b7963aa4e47e70953446f6a89a5/height=288;version=1;width=512/https%3A%2F%2Fblogger.googleusercontent.com%2Fimg%2Fb%2FR29vZ2xl%2FAVvXsEjHwQbvwsrtpDC2W_BqI_8KRHA2pM_VM-8EjsxlSznf7FrbQL0pq7Herhw-HQl_1xtDFzlWkYFqDZM3WFTjeswwy1saL0NgImYbvynpUwCZDBkOQpF-Vtcbos-mirBDcxExwphQRoQxpoQe%2Fw1200-h630-p-k-no-nu%2Fdevice-2020-11-10-122925.gif)