Landscape Dialog with Portrait Activity - android

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.

Related

How to force activity always appear in portrait orientation without delay in lockscreen?

I have an activity with "portrait" orientation in AndroidManifest.xml.
When I start it from lock screen in landscape orientation, it appear with landscape for 1 second, and then change to portrait. The delay happens even if it's an blank activity (no view, no task).
Tell me how to avoid this delay. Remove transition effect, rotation effect? I know it could be device performance, but still want to fix this.
If you always wants to run your app in landscape mode than use this code in Manifest file for all activity
<activity
android:name=".yourAcitvity"
android:launchMode="singleTask"
android:screenOrientation="landscape"
android:configChanges="orientation|screenSize"
/>
That't the default behavior of Android, you can verify this issue using system apps. For ex: open the Android's default messenger, and turn it to landscape and lock the phone, now unlock it and you can see the messenger has re aligned to portrait, that's because the home screen is set to portrait by default. In order to show the home screen the system aligns the device to portrait again.

Alert Dialog not changing to landscape/portrait layout on orientation change

I have a custom AlertDialog which is opened by a button click. I have made two xml layouts for it. Normal portrait layout and landscape which I put into res/layout-land folder. When dialog is opened, I change the screen orientation and it won't refresh to apply respective xml layout. But if I open the dialog after I changed orientation, correct xml will be inflated.
I have tried with and without this line in my AndroidManifest.xml,
android:configChanges="orientation|screenSize"
and without it, it is even worse. Dialog gets closed and the keyboard is opened. I don't know what is going on there. One way would be to reopen dialog by hand, but I don't know how to do that either. I'm starting a dialog on a button click inside fragment's onCreateView. Other than that, I don't have any other method set up regarding AlertDialog.
Thanks in advance!

How can I use a portrait layout in a Dialog Activity, when screenOrientation is set to landscape in the Manifest?

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.

how to force landscape mode for dialog?

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

Android Search dialog in landscape orientation

I'm using an android search dialog in my app, and it works fine in Portrait orientation. But as soon as you flip to landscape orientation the searchpage xml appears to be covered by a large white dialog box. If you do a search, the box is still there, and you hit the back button on the device or emulator, the large white box slides away and there are your search results. It seems like somehere in the code a layout width is set to fill_parent or something. I've looked around for a solution and someone suggested adding android:imeOptions="flagNoExtractUi" to seachable.xml in the xml folder, but that doesn't seem to have any effect.
I've discovered that it's the onSearchRequested(); method that is throwing up that white box that fills the screen. And it also may have something to do with the fact that the software keyboard isn't called when in landscape, vertical orientation.
You could create your own Dialog in the form of an Activity. You do that like this:
<activity
android:theme="#android:style/Theme.Dialog"
android:configChanges="keyboardHidden|orientation|screenSize"
android:name="ExampleActivity" >
</activity>
This Activity can of course be arranged any way you like via the XML. This way, you can gracefully handle the change from portrait to landscape.
Note: You only need the "screenSize" attribute if you are using ICS (14+).

Categories

Resources