Landscape layout - android

Can i handle size of item in xml file when i'm in portrait or landscape mode?
Thanks

What do you mean by "handle" ? If you have 2 layouts, one for portrait and one for landscape then you can change the size of an item in the xml file - so long as you respond to the rotation correctly and change your layout then you should be ok

If I understood your question correctly, you can create two xml layout files for that activity and place them in layout and layout-land folders respectively. Then the system will automatically take the proper layout for the proper orientation.

Related

How to set different layouts for different orientations in a fragment

I have an activity which contain 3 fragments. 2 of them have data in a listview therefore when user rotate the screen everything is ok. but on my third fragment which contain buttons, when the user rotate the screen to landscape orientation,everything goes astray!
my third fragment in protrait orientation
my third fragment in landscape!
I have even tried to use scrollview but it's not working because when in landscape i don't want that big space at the middle. i wan't 3 x 2 buttons arrangment(i have 6 buttons.) when in landscape. and i think i can only achieve that by using 2 xml layouts for my fragment.
Question is how can i do that?
Make another layout folder layout-land under res and create landscape orientation layout file under this folder
After great help from sai Phani(see his comments above). i finally achieved my objective which was to create a landscape layout for my fragment by doing the following.
Create a folder under src\main\res and call it layout-land
copy your fragment layout xml (e.g peoplefragment.xml) which is in src\main\res\layout and paste it into src\main\res\layout-land folder. Don't change the file name!
Once you have pasted it, you can change the views alignment the way you would like them t appear on landscape. for my sutuation, i wanted them to appear like this in landscape
You may design your layouts that looks good for both portrait and landscape but you may customize for both orientation.
Look at SO link on the same issue # Android: alternate layout xml for landscape mode. The idea is simply to create folder names the correct way specified in Google documentation.
A good Google webpage is # Supporting Multiple Screens, search for "Using configuration qualifiers". There is a table stating Orientation and the folder names to use.

layout display height issue on rotation mode

i create a app with some forms, they display right i want, the problem is on rotate screen, the form width it's ok but the layout height i have a issue because it don't display all items of the layout, trying to find a solution i put a scrollview for the linear layout, it works but, some of this forms have listviews inside, so the listviews scroll property has been blocked by the scrollview and finally i can't display all the layout info. I want to know if some one knows a solution for this issue and can help me.
follow below steps.
1) create a folder in res directory as res/layout-land.
2) suppose you have main.xml layout in res/layout folder.
3)Create one layout name main.xml into res/layout-land folder, name this layout as main.xml. design you UI as you want to show to the user in Landscape mode.
Now when you run your app and change Orientation . system automatically called main.xml according to the Orientation, SUppose phone is in Landscape mode, then it will show main.xml of layout-land folder
see this example

Button self "rearranging"

Wondering how I do build a layout with self rearranging button, when the user turns his device from portrait to landscape, using relativelayout ?
I do not want to use scrolling on my layout and I have a lot of buttons
You can provide two different main.xml (or any layout xml file) Place one in res/layout/ and one in res/layout-land/ When the device switches orientation the system will handle the "magic" of switching to the appropriate file.
Here is some documentation about supporting these type of behaviors...
If I'm understanding your question correctly what you are looking to do is have one layout displayed for portrait mode and another for landscape mode. This is actually fairly easy to accomplish.
Here is a link to a quick tutorial:
How to change your layout in Android landscape / portrait mode

How to add an XML File to Current Activity Window in Android

Hi guys in my android application i have used Tabs through out the application.When iam in the Portrait orientation i need to display the Tabs.Whenever iam in the Landscape orientation i need to put a layer just above the TabBar so that the TabBar will be in the background.Here in the Landscape orientation the background TabBar runs ,that is just we have added one layer on top of the TabBar.And also i need to display different layout in the landscape orientation.I have heared about the Window object of the Current Activity that we can add a XML layout to the Window and makes it visible and invisible whenever we require.But i haven't find any code regarding Window.Any Suggestions
You can define different layouts for each orientation. For portrait layouts use the layout-port folder, for landscape use layout-land. Android will choose the right one depending on the orientation of the device.
See http://developer.android.com/guide/topics/resources/providing-resources.html

how to track the screen in landscape or portrait view in android?

I worked in a tabactivity, I set the gravity for tabs as bottom. If I change the screen from portrait to landscape, I can't see the tabs.
How can I do it? I need an example please.
Thanks.
Assuming you do not have a separate XML file dedicated to landscape format, you might need to create one and specify the landscape-layout look.
Create another main.xml file with the specifics of how your program should look in landscape mode. The file shoud reside inside your res/layout-land/ folder.
When that is all said and done, in potrait orientation, Android will use main.xml found in res/layout and in landscape main.xml found in res/layout-land.

Categories

Resources