Allowing Landscape mode for specific part of the app only - android

I'm developing an Android Application which is locked to portrait mode for phones. In one part of the application, the user can look at some nice Graphs. In this part (only), it would be nice to allow the user to change to landscape mode - if he wants to.
I know this would be quite simple if the Graphs were contained in their own activity, but unfortunately, they are not. They are shown by Fragments which in turn are shown in a somewhat complex Tab Layout.
In other words; I want to have to whole app locked to portrait mode except when the user is in a specific Fragment. Then I want to allow him to allow him to change to landscape mode (Not neccessarily by rotating the device, other solutions are welcome too). When the user navigates away from that part of the app from Landscape mode, the portrait mode should be restored.
Is there any way this can be achieved?

you can do it dynamically this way :
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

Related

Random landscape layout issues

I have build android application and in manifest I have android:screenOrientation="sensorLandscape" also I use android:configChanges="locale|keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize" I mention it just because maybe it can be related to my issue.
When I turn my phone to portrait and press home button to go to home screen and go back to my app in portrait it sometimes get displayed in portrait for a second and the it switches to landscape but this happens just very rarely.
Also I get random layout changes like you see in pictures. This all happens just like this I turn phone to portrait while my app is supposed to be landscape only based on my manifest definition.
My guess is that somehow android system is switching my app to portrait before recognizing it as landscape but I don't know how to fix it. I would like to to stay sensorlandscape too so I get it rotated for both landscape orientations. Maybe this is phone specific behaviour and some others don't do it (thats even worse then), hard to say app is not released yet...
On first picture you can see correct layout and others are how it gets randomly corrupted by having phone portrait and going to home and back to running app again...

Website in mobile landscape, keyboard layout issues

In a website I'm designing, I'm using the following layout to ask for a user's phone number:
This is fine on portrait orientation. However, on landscape orientation, at least with Android, I'm getting this:
I can save some space by maybe hiding the navigation bar, tweaking some pixels here and there, but still, this appears to be a sub-optimal user experience. I looked into orientation locking, but this works only for full-screen applications, or websites that have been added to the homescreen. Is there another way to prevent the keyboard from taking up more than 80% of the screen?
I think this is normal , the main issue is your mobile have a small screen

In-built android app to run only in landscape mode

I have developed an application that runs images and videos (with a default application to display them) for a certain time period.
However I want to run all these images and videos only in a landscape view. I want to lock this, irrespective of rotation settings. If possible, I would also like make it to only portrait view in future. Please advise.
It is not possible to change device orientation programmatically, you can redirect user to those setting but not possible to change from app side. e.g you can redirect user to GPS setting screen but not set it from app. Same concept apply for rotation as well.

Fragment best practices

I am making an application and I just began using Fragments finally, after reading all of the documentation, I got to here. I designed the application so in portrait mode it is two activities, the chooser and the details, while in landscape left is chooser right is details, on a tablet. Now, this works fantastic like in this image:
however, now when I turn the Handset into landscape, it does the same thing as tablet does in landscape, has the two fragments. First, I would like to know should I leave it as the two fragments on the handset too? Would this be the "best practice"? If not, I would like to know how to go about making the landscape like the portrait without messing up tablet landscape.
Thanks
You'll need to have two separate layouts, one in a layout-port (for portrait) and one in layout-land (for landscape). Your portrait layout should contain just one fragment. In your activity you'll need to check for the presence of that fragment, or the view that contains it (if you are using FrameLayouts), and act accordingly.
See this from the developer site.

Dialer in landscape mode

I have written a dock app that utilizes the stock dialer within android but it always displays in portrait mode is there a snippet that I must include to get the dialer to respond to being in the dock. How do I call the layout that the stock dock program does?
Thanks in advance.
You can tell the user to put it in a dock, I suppose. If the device is in landscape mode, and the application does not support landscape mode (e.g., the dialer on my Nexus S), that is just the way it is.
More generally, you have no right to dictate how third party applications should look and behave, any more than other people have the right to dictate how your application should look and behave. The application will look and behave how its developers designed. If they have different layouts for landscape or being in some sort of dock, they will use those layouts... when they are in landscape or in some sort of dock.

Categories

Resources