I am using a Spinner with android:spinnerMode="dropdown". I have also set android:configChanges="orientation|keyboardHidden|screenSize" to prevent my Activity to get recreated. when I am in Landscape mode and click on Spinner it pops below the Spinner and have the width same as Spinner button, now when I rotate the screen to portrait mode the Spinner button width get reduced according to the screen size but the pop up dialog does not reduce its width accordingly.
Portrait mode screen:
LAndscape Mode Screen
I thought of closing the pop up and reopen it on screen orientation but I didn't found any way to close the pop up dialog.
On the onConfigurationChanged() method call to spinner.invalidate();
I had this issue as well. I ended up calling notifyDatasetChanged() on the spinnerAdapter in onConfigurationChanged() and it worked.
Related
I have an Activity that has android:screenOrientation="portrait" options set in AndroidManifest.xml.
At all times, I want this Activity to stay in portrait mode.
However, one of the buttons opens a dialog that has SignaturePad widget, provided by this library.
Because user has to sign with their finger/stylus, I want to make the Dialog landscape so there is more space to sign.
Is it possible to change Dialog's orientation without changing the Activity's orientation?
I've tried DialogFragment, system level dialog (TYPE_SYSTEM_ALERT) and few other things. Nothing seems to work.
Okay so I have a simple ListPopupWindow assigned with String[] and in portrait works great.
If I open the List and then change the orinentation it messes everything up.
When I show the Popup for first time in portrait:
When I change orientation while the Popup is opened:
When I open it while in landscape mode:
I want while is opened and I change orientation to go to the button view, and when I open it in landscape mode to be wrapped because if I want to choose about or help and feedback I am not able because its not scrollable. How can I achieve that?
I have an activity, let's call it HomeActivity, whose screenOrientation has been set to landscape in the manifest file.
Clicking on a button in the HomeActivity presents a Dialog Activity which floats over HomeActivity.
There is a portrait version and a landscape version for the layout that is to be displayed in this dialog, but for this scenario, only the portrait version should be displayed.
In the onCreate() method of the Dialog Activity, I've requested Portrait Orientation but this causes both the dialog and the HomeActivity behind to rotate to portrait mode. I do not want this.
Is there a way to set the orientation of the top most activity without affecting the orientation of the "behind" activity?
Thanks for your help?
Orientation is system-wide property so it can only be landscape or portrait at the one time. This includes all displayed activities (including dialog), status bar and buttons.
You have to display HomeActivity and Dialog Activity with the same orientation.
Also, forcing Activity orientation in the manifest is a bad practice in general.
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?)
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
Is there a way to showing a dialog always in portrait? I need that because of its layout.
I know that I can set that for an Activity with
android:screenOrientation="portrait|reversePortrait"
But what about a dialog?
At the time of the dialog showing, check the device's orientation.
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
int orientation = display.getOrientation();
//if orientation is portrait then show, if not then don't.
Not sure these ways will fit your requirement ,
One way is showing Activity as a dialog with screen orientation set to portrait (with dialog theme)
refer DialogActivity from ApiDemos
Other way is forcing activity to change its orientation by
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
and open dialog in onConfigurationChanged() (with some logic).