How to force landscape mode for dialogue?

Imagine that your activity (forced!) in portrait mode, and you will see a dialog from there, but in landscape mode (because it contains a view larger than the screen width), how do you do it?

I think the screen orientation on the screen depends on its hosting / service.

Is there another way? (for example, the default forced orientation for the dialog box above its xml file layout?)

+4
source share
1 answer

If you are under DialogFragment Use in the dialog box create getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); and through the dismiss dialog getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); if you do not want the activity to be updated, also add android:configChanges="orientation|screenSize" another way, you will have to handle the recreated activity.

+2
source

Source: https://habr.com/ru/post/1437347/


All Articles