Landscape include layout in Portrait orientation - android

I'm currently developing an app that will show a physical representation of an ID card, i have this view as an XML file on both landscape and portrait mode.
My question is: is it possible to have the phone in Portrait mode and use only this layout as an include in landscape mode? The goal is to have a nice elegant ID Card shown on the screen like the picture here. Thank you.
Edit: so in other words I need to use a LANDSCAPE resource while being on PORTRAIT mode.

You can add android:screenOrientation="portrait" to your Activity in the manifest and this will lock the Activity in portrait mode.

Related

android TV NEXBOX A95X screen orientation portrait

I want to display my screen always in portrait mode on TV(NEXBOX A95X). I have set android:screenOrientation="portrait" to Activity on Manifest file. But it is working on mobile devices but not working on TVs. It is displaying horizontally in landscape mode. Any help will be appreciated. Thanks in advance!

Android Layout Folder for Devices/Tablets which are always in Landscape

I'm developing an android app for phones and tablets.
I want all of the devices to use portrait layout. I made a 'layout' folder for it. But, there are some X number of devices which are always in landscape mode. Probably, large tablets. So, I made a 'layout-land' folder too.
Which folder I need to add so that X amount devices will always display landscape layout only, while other devices will always display portrait layout?
Main requirement is to have only portrait layouts displayed. But, display Landscape layout when device itself is in landscape mode(default). I am talking about devices that display drawer in landscape mode, and the ones that open landscape layout of apps only.
Is this automatic?
I have android:screenOrientation="portrait" in manifest.
I can't test this as I don't have a tablet/large device.
I have already looked at this question and other similar questions.
Add the below line in your onCreate() method before setContentView()
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORT‌​RAIT);

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

how to get landscape view when i changed portrait to land scape?

I have implemented an application for android 7 incs tablet.In my application i have used two types of layouts in layout-land and layout-port directories with same xml name and different designing.
In this application the tablet view is in landscape mode as by default when i change the orientation of emulator the the view is calling portrait xml from layout-port and if again change emulator orientation it is not getting xml view from layout-land.
I have implemented my application as follows:
if(wm.getDefaultDisplay().getOrientation()==1){
//portrait view code
}
else{
//landscape view code
}
from the above logic i can get the view from land scape to portrait but i can't get same view portrait to landscape.
How can i get my land scape view when i change landscape to portrait to landscape?
please any body help me?
That seems to be a problem with the emulator. You don't have to implement from code the orientation changes, since the system have by default this behavior. Just place your xml files in layout-land and layout-port and on a real device it will work fine.
The bug has been reported and you can see this here
You can use this code:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
or
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
You maybe also have to set this in your manifest under activity:
android:configChanges = "orientation"

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