How to specify a reverse landscape layout in android? - android

My application supports both landscape and reverse landscape. When the user rotates to reverse landscape Android shows my same layout. I would like to provide a reverse landscape layout to be used in reverse landscape orientation. Is this possible?

It does not seem like this is possible.
The resource qualifiers only distinguish between port(trait) and land(scape) and also if you'd handle configuration changes programmatically, Configuration.ORIENATION only can be Configuration.PORTRAIT or Configuration.LANDSCAPE. No 'reverse landscape' there...

Related

Is there any way to change the orientation of the layout shown in the second screen when using cwac-presentation library?

I have an app that uses the cwac-presentation library. When starting the service and displaying the layout on the second display, I want it to be landscape oriented but keep the layout on my device on portrait, but I cannot find a way to these different orientations. If I request an orientation change, it happens on both screens (as expected). Has anyone found a solution to this issue?

How can I make my android tablet app to look the same when it runs on phone in landscape mdoe

I have a android app layout for tablet. Its layout is 'landscape' based (i.e. it looks the way i want when I run on tablet (by default landscape).
But when I run the same app on a phone, android runs in portrait mode, (it squeeze my 'landscape' layout into a portrait ).
I have tried putting 'android:screenOrientation='landscape' in my activity in my Manifest file. But that does not fix it.
Basically, what I want is when I rotate the phone by 90 % (the width is > height), I want the phone layout looks the same as what i see on tablet (which is landscape by default).
How can I do that? android:screenOrientation='landscape' does not work.
Basically, I want some thing the game 'AngryBird', it always runs in landscape mode regardless it is phone or tablet and whether the phone is rotated.
I think you need to use 2 flags, not just one.
First is
android:screenOrientation='landscape'
Second is
android:configChanges="orientation"
First will tell android to run activity in landscape mode, where as second will tell android that do not change the orientation even when user rotates the phone. Basically with 2nd flag you are overriding orientation config changes.
Haven't done this myself, but instead of putting the main.xml layout in res/layout, try putting it in res/layout-land, so it will display this layout in landscape mode, and in res/layout-port, maybe a portrait alternative to main.xml?
Create folder \res\layout-land\ and place there your XML file with landscape layout. Phone choose between portrait and landscape layouts automatically.
Add this line in the onCreate method before you call setContentView:
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );

Which layout should be in landscape in android?

I have downloaded the google io application and I noticed that for landscape layout, its only the dashboard layout that have a landscape layout (in the layout-land folder).
My question is the following, is it for all the layout available in our project that we must create a landscape layout or it is only for the dashboard layout?
Thanks.
Kind Regards.
You are allowed to create a landscape layout for any layout in your app. You should do this when you want to have a different layout in portrait vs. landscape. Sounds to me like the Google IO app specifies a different landscape layout for only one screen (the home screen/dashboard), presumably because that's the only screen the developers felt needed a different landscape layout. Point is, it's up to you which screens have alternate layouts.
It depends on the data you have to show.
Sometimes there is more data which can be shown because of extra width in landscape and you have to compress data vertically in landscape. For such cases use different layouts

Screen Orientation of Android

Which is more appropriate to use in Screen Orientation.
Declaring <activity android:screenOrientation="sensor" />
or
the long process of creating a new folder layout-land & a new layout? and why? I'm using the first
one now and seems it has the same function as the latter. Thanks!
I think the two are different. When we use android:screenOrientation we're telling android what orientation we want to be displayed in. Having two layout's, one for portrait and another for landscape helps us in cases where we want to layout our views such that it takes advantage of the increased width. If you don't think if need this then just use a single layout. Android will use the same for both orientations.
If you want to prevent android from displaying your view in a particular orientation, etc you can use the former.
sensor just returns the orientaton of the device. It does not optimize the layout like using layout-land would.
From http://developer.android.com/guide/topics/manifest/activity-element.html#screen
The orientation is determined by the device orientation sensor. The
orientation of the display depends on how the user is holding the
device; it changes when the user rotates the device. Some devices,
though, will not rotate to all four possible orientations, by default.
To allow all four orientations, use "fullSensor".

how to add scrollview to screen in android?

I have done my application in portrait configaration but when load my application in to device its coming portraint configaration but I keep in landscape mode missing some controls. So I want to add scroll view to screen when changing the config to landscape. How I can add ScrollView to screen ?
You could define two version of your layout.
"res/layout/your_layout.xml" - this will be used in portrait mode
"res/layout-land/your_layout.xml" - android will use this when in landscape orientation
If you don't want to do to many changes in your layout you can add ScrollView to landscape version of your_layout.xml.
Regards!

Categories

Resources