Wicked161089
Wicked161089

Reputation: 481

Change Orientation of a Dialog

I have a problem. I have an App, which has a fix orientation (portrait) set in the manifest.xml.

android:screenOrientation="portrait"

But I do want to change the orientation of an Dialog, that I create programmatically in one of my fragments. Problem is, that the super method onConfigurationChanged(Configuration newConfig)is never been called, because of my manifest declaration.

Is it possible to detect that the phone has been turned and change the orientation of the dialog (Without destroying / recreating everything like normally)?

EDIT:

"Activity and Fragments should stay in portrait mode, Dialog should detect changes and orient"

Hope this question is understandable ;)

Thanks!

Upvotes: 2

Views: 2440

Answers (2)

VinhVox
VinhVox

Reputation: 1

We had to do this in a fullscreen dialog launched from a service.

override fun onStart() {
    window?.attributes?.screenOrientation = SCREEN_ORIENTATION_PORTRAIT
    super.onStart()
}

and it works fine

Upvotes: 0

Lord Sidious
Lord Sidious

Reputation: 359

I think that a viable solution would be to remove the android:screenOrientation tag and then override the onConfigurationChanged() method to do what you need.

Upvotes: 0

Related Questions