ダイアログを常に縦向きに表示する方法はありますか? レイアウトのために必要です。
私はそれをActivityに設定できることを知っています
android:screenOrientation="portrait|reversePortrait"
しかし、ダイアログはどうですか?
ダイアログを常に縦向きに表示する方法はありますか? レイアウトのために必要です。
私はそれをActivityに設定できることを知っています
android:screenOrientation="portrait|reversePortrait"
しかし、ダイアログはどうですか?
ダイアログが表示された時点で、デバイスの向きを確認してください。
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int orientation = display.getOrientation();
//if orientation is portrait then show, if not then don't.
これらの方法があなたの要件に合っているかどうかわからない、
1 つの方法は、Activity を画面の向きを縦向き (ダイアログ テーマを使用) に設定したダイアログとして表示することDialogActivity
です。ApiDemos
もう 1 つの方法は、アクティビティの向きを強制的に変更することです。
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
ダイアログを開きますonConfigurationChanged()
(いくつかのロジックを使用)。