Force landscape when pressing button - like youtube full screen button - android

Hey i'm trying to create a behavior like YouTube full screen button.
I have a button that will force rotate from portrait to landscape.
And it should stay in landscape till the user rotates the device to landscape and back to portrait.
My problem is that when i use getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)
And the phone is in portrait the view rotates to landscape for a second and Straight back to portrait.

Related

Show only one view in full screen in landscape mode when screen rotates

Integrated MPAndroid Line charts, when screen rotates to landscape I want to only graph view to be shown in full screen and all other things should be hidden. I have restricted orientation to "Portrait", how can I trigger when screen rotates to landscape even though it is restricted.
you can duplicate the XML layout file of your activity, and put it inside folder /res/layout-land if you don't have it create it. Then you can change the visibility to "gone" at the views you don't want to show in landscape mode.
Also don't restrict the orientation to portrait for this activity

Keeping the current orientation

My app does the following:
I take a picture
The picture is displayed in a DialogFragment
If I take the picture in landscape mode, I want the orientation of the DialogFragment which is showing my image to be locked to landscape mode.
If I take the image in portrait mode, I would like the orientation of the DialogFragment be locked to portrait mode.
Is that possible?
Check the width and height of your image, that should be enough to tell you wether it was taken in portrait or landscape mode. Set your orientation with
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
And if you want to re-enable your auto-rotate functions at a later time just use
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);

Android keyboard rotation

Is it possible to disable orientation changes for an activity but still be able to rotate the keyboard?
I would like to be able to write text in landscape mode but keep the activity mode fixed in portrait mode.

Faking landscape orientation in Activity when locked in portrait

The camera app on Android locks its orientation to portrait, and fakes an orientation change when you turn to landscape. The screen never re-orients itself (you don't see the screen reload or shift at all), but the icons turns to make it seem like it changed the orientation. How are they achieving this?
Let's say I did this. So I'm locked in landscape mode, and I rotate the phone so I'm in portrait (at least that's what it looks like to the user). Now if I have any dialog that pop up on top of this Activity, I'd want them to pop up in portrait orientation. How would I achieve this?

It is possible to lock the screen orientation of the phone only when you want? (dynamically)

I have an application that can be viewed with landscape and portrait mode. I'm not using onConfigurationChanged() and android:configChanges="orientation|keyboardHidden" and the screen orientation change is working perfectly.
But now, i have a small problem. I want to learn to lock the screen orientation change of the screen. I mean that for example, when the user press a "lock" button, the screen orientation must be locked and it must not change, and when the user press again that button, the screen orientation must get unlocked
¿how can i lock the screen orientation dinamically?
For locking,
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
For unlocking,
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
where "activity" is your current Activity, in which you want to lock.

Categories

Resources