Dialog should not deviate when changing screen orientation

I created a custom tab that has two different drawings for portrait and landscape orientations. Icons for portrait screen are under drawable-hdpi, while landscape images are under drawable-land-hdpi. At the moment, I have placed the configuration of the changes in the manifest in order to maintain the visibility of the dialog.

android:configChanges="orientation" 

Whenever a dialog box is displayed and the user changes orientation from portrait to landscape, the dialog still shows, but the images that he uses in the activity of the tabs are for portrait mode. That is why the layout for does not look right, since he did not use drawings for the landscape. Can someone help me with this? Thanks.

+4
source share
3 answers

If you use android:configChanges="orientation" , then Android will not re-create activity when the orientation changes. If you do not want to reject the dialog, just use the Activity.showDialog() method. And if you still want to use android:configChanges="orientation" , you need to manually change the drawings in the Activity.onConfigurationChanged() method.

+3
source

Add manifest.xml to your application shortcut

 <activity android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|screenSize" android:name=".your.package"/> 
0
source

You can execute an arbitrary implementation of the layout by specifying an orientation mode, as shown below:

 @Override public void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); if(config.orientation == Configuration.ORIENTATION_LANDSCAPE) Log.i("orientation", "Orientation changed to: Landscape"); else Log.i("orientation", "Orientation changed to: Portrait"); } 
0
source

All Articles