Which layout should be in landscape in android? - 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

Related

Android studio switching layouts when device rotates

I am making my 1st ever android app using android studio,
Everything works correctly except switching between portrait and landscape layouts.
What code do i need to insert and, where to get my app to see the layouts I have made.
Thanks
Michael
You have to create a new folder called layout-land and place it in there.
Ex:
Your layout's current location is layout/my_layout.xml, you would place the corresponding landscape layout in layout-land/my_layout.xml
Check: http://developer.android.com/guide/practices/screens_support.html under "Using configuration qualifiers"
Similar Question:
How do I specify different layouts for portrait and landscape orientations?

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?

Force orientation depending on the View inside ViewFlipper

I have a ViewFlipper with several ScrollViews inside. Depending on the child ScrollView I need to force the ViewFlipper's orientation to portrait or landscape. How can I achieve this ? Thanks.
Take a look at http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/reference/android/widget/HorizontalScrollView.html
In the first document, note that you can provide different layout files for landscape versus portrait modes. For example, for landscape mode, you could have a layout file in res/layout-land.
If you want more help putting the pieces together, just ask.
Edit: It looks like I misread the original question. Take a look at these two posts:
Force an Android activity to always use landscape mode
Android force Horizontal (landscape) layout

Android Screen Orientation

I developed an application in portrait mode in Android.
What changes do I have to do, that my application will be also fit for landscape orientation?
Thanks in advance.
Technically speaking, you don't HAVE to make any changes for it to fit to landscape. It you're using the standard wrap_content and fill_parent for your width and height, your layout will automatically adjust when you change orientations.
With that said, you will often WANT to change to a different layout when switching from portrait to landscape, as a layout that looks good vertically may be unusable when horizontal. You can add a new folder beside your /layout folder titled layout-land. In this, make a new XML file with the same title as your previous layout, and then change the layout from there. Be sure that any and all defined android:ids exist in both the original and landscape layout.
Make sure you use layout_width as "fill_parent" where ever required.

Best way to deal with different Android screen sizes?

We are writing an application for the T-Mobile MyTouch which is an Android based mobile phone. We have images that will be displayed on the default screen portrait mode (320 x 480).
Anticipating that the Android OS will be appearing on Netbooks with default landscape 16 : 9 screen format, what is the best way to handle images that are in a portrait mode format? In other words since you can't rotate the screen on these Netbooks, if you display a portrait mode image on landscape mode screen there will be large blank rectangles on either side of the image.
In terms of image resources within the application, such as is the case with background images, it is a common practice to have different image set for landscape and portrait mode, or even different screen sizes. Surely, you will adapt your layout to it, or at least have a good relative layout.
However, if you are wondering what to do when an image of an unknown size has to be drawn on the screen (e.g. in case of photo album application), it is fine to leave those black rectangles on both sides. Take a look at the behaviour of video player view on the Android Dev Phone 1. It will adapt the video frame height to landscape mode, and it will play the video in the landscape mode whether or not a portrait mode is more suitable.
You deal with it the same way you would deal with the user turning their phone sideways. This is as much a presentation decision as a UI one.
Remember Android supports using alternative layouts for identical Views. If you have a portrait layout e.g. res/layout/gallery.xml, you can create a landscape equivalent in res/layout-land/gallery.xml and Android will automatically load the latter layout file if the Activity is launched in landscape mode.
With the separate layout XML file, you can then arrange your image as you feel best fits the intent of your application (an application displaying medical images may well have different presentation priorities than one displaying a family portrait). You could for example just fill the background with a gradient, or more information that is otherwise hidden in portrait mode. It all depends on what you wish to achieve with your application and the lengths you are willing to go to to account for all possibilities.
But ultimately, provided the user can see the image in it's entirity without needing to flip their netbook on it's side, I imagine they'll be happy :)
You should design your screen with certain anchor points and then position the rest of the views in relation to those anchor points. For example if you have a screen layout which has a banner, a list of items and some buttons under the list then 2 of the ways these can be positioned on the screen:
Place banner at the top. Put the
list under it and then the buttons
under the list.
Place banner at
the top. Place the buttons at the
bottom of the screen and then the
list takes the space between the
banner and the buttons.
Layout 1) will have trouble with different screen sizes and the layout will look odd or may not appear correctly at all. Whereas, 2) gives you a better appearance for most screen sizes.

Categories

Resources