Prevent orientation sensor using portrait as default - android

I'm using orientation="sensor" in my Activity. If I start my app in portrait everything works, if I latter change my orientation everything works too (being in portrait or landscape) but if I start my app with my device in landscape, instead of my Activity being launched in landscape (like when it does if orientation="landscape") it first starts in portrait and then changes to landscape.
I want to avoid that, I want to have orientation="sensor", but with the Activity launching in portrait if the device is in portrait or in landscape if the device is in landscape.
How can I achieve this?
Thanks.

Related

UI is not changing as expected while changing orientation in android

Here I am using different UX designs for portrait and landscape mode for a particlular activity. Created the folders layout-sw600dp and layout-sw600dp-land ,layout-sw720dp and layout-sw720dp-land for portrait and landscape mode. But the corresponding UX is not displayed while changing the mode. That is it loads the launching mode's expanded version while rotating the device. This means it will show the expanded version of landscape design while changing that to portrait. Tried the below code in the manifest. But no hope.
android:configChanges="keyboardHidden|orientation|screenSize"

ConstraintLayout breaking when switching from Portrait to Landscape mode

Right now I have two different layout files, one for Large and one for large-land. Both are using constraint layouts. However whenever the tablet switches from portrait to landscape mode, the landscape mode layout displays correctly. But after switching back to portrait and back to landscape mode, the landscape layout no longer displays correctly. The right side of the layout seems to have extended past the actual screen.
To simplify,
Portrait -> Landscape: Landscape displays correctly
Portrait -> Landscape -> Portrait -> Landscape: Landscape layout breaks and extends past the screen for some reason.
Any idea why this may be happening? Thanks in advance!

Change NativeScript XML layout based on orientation

I have a question about NativeScript orientation (Landscape and Portrait).
Is it possible to check if the device orientation is landscape or portrait and based on that switch the XML layout file? For instance, use lay.land.xml for landscape and lay.port.xml for portrait.
Thank's for all...
NativeScript already does this out of the box. Name your files <file-name>[.<qualifier>]*.<extension>
land - orientation is in landscape mode
port - orientation is in portrait mode
Note: All qualifiers are taken into account when the page is loading. However, changing the device orientation will not trigger page reload and will not change the current page.
This is documented here: https://docs.nativescript.org/core-concepts/navigation#orientation-qualifiers

android layout-land and screen-rotation handling

I have layouts for portrait mode (in folder layout) and for landscape one (in the folder layout-land). This screen is located under one of the tabs, so I had to handle screen rotating (after screen has been rotated, no default screen restart occurs).
I would like to update view from 'layout-land' when screen rotates to landscape mode and from 'layout' when screen rotates to portrait one.
How can I do this?
You can use onConfigchange method in that setContentView(R.layout.name) this way will work.

froyo's universal rotation and my landscape only app

My app is set in landscape only mode thanks to an attribute in my manifest file, but with froyo came universal rotation and a problem. It will force the screen to landscape but if the user is holding the phone upside down my app will appear upside down. Is there a way for me to set my app to only rotate when the user has their phone orientented in both landscape positions?
I have one app in landscape mode and put in manifest this attribute:
android:screenOrientation="landscape"
Put this into activity and works fine for me (Froyo 2.2 Nexus One)
... By the way sorry for my english

Categories

Resources