9

imagine your activity is (forced!) in portrait mode and you'll show an dialog from there, but in landscape mode (because it's containing view is larger than screen width), how will you do that?

I think the screen-orientation of a dialog depends on it's hosting activity/service.

Is there still a way? (e.g. force default orientation of dialog view over it's layout xml-file?)

user1480734
  • 141
  • 1
  • 6

1 Answers1

4

If you are under DialogFragment Use on dialog create getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); and on dialog dissmiss getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); if you don't want activity recreate add also android:configChanges="orientation|screenSize" other way you will have to handle activity being recreated

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
Pedro Teran
  • 1,200
  • 3
  • 17
  • 43