I created following layout folders.
res/layout-sw320dp
res/layout-sw480dp
res/layout-sw600dp
res/layout-sw720dp
It is ok, layout from corresponding smallest width in dp folder are triggered.
Is it sufficient to create these four folders and our app will looks fine on any density screen or any size screen ? Plz explain this in some detail.
To create layout for landscape mode. what can i do with this ?
what is the use of multi port ui using fragments ? Is it used for landscape and port-rate layout in one xml file ?
By default, the layouts in /res/layout are applied to both portrait and landscape device screeens.
For example you have main.xml
/res/layout/main.xml
you just need to add a new folder /res/layout-land, copy main.xml into it and make the needed adjustments, and so on for all of your layout files.
You just need to have same files for land and portrait but with different folders and of course with different modifications.
Hope this to help!
Related
Hi is it possible that in my android application buttons which are there in vertical orienatation change to tabs in horizontal orientation . So they can fit better for tablets ?
one way is to create 2 folders called layout-land and layout-port, write 2 different xml's with same name and put them in layout-land and layout-port
for example if you have a home.xml
If you put home.xml in layout-port folder, when your device is in portrait orientation it will use the file: layout-port/home.xml.
If you put home.xml in layout-land folder, when your device in landscape orientation it will use the file: layout-land/home.xml.
You have to create separate XML files for portrait and landscape modes and place it in different directories. The device will automatically select the right one. You can use the following directory structure
res/layout/my_layout.xml
res/layout-land/my_layout.xml
For more details read this doc.
Yes, it's definitely possible.
Have you check this one? Basically it's using the Resources in your Android project. You can create the following folders:
res/layout/ //portrait
res/layout-land/ //landscape
Have a layout with the same name but different content depending on what you want.
for 7 inch tablet:-make a new folder in res/layout-sw600dp-port for portrait mode
and res/layout-sw600dp-land for landscape mode
for 10 inch tablet:-make a new folder in res/layout-sw720dp-port for portrait mode
and res/layout-sw720dp-land for landscape mode
for phone layout upto 5 inch screen,just design your screen in layout folder
hope this will help you
!!Happy Coding!!
I have divided my layout resources in Android project to many folders such asL
layout, layout-large, layout-normal-port-xhdpi-800x480, and so on.
The problem is when I click on xml file inside the (layout) folder which is the default folder it always opens in landscape; I tried to switch to portrait but it opens the xml file inside (layout-normal-port-xhdpi-800x480) folder.
How can I view the default layout as a portrait not landscape?
Appreciate your help.
I would suggest using the new layout qualifiers.
See here: Support Multiple Screens
layout-sw600dp (7Inch Tablets)
layout-sw720dp (10Inch Tablets)
etc.
They're all listed there.
I know you can specify a different layout file for orientation by creating a directory;
layout-land
And I know you can create another layout file for a large(tablet) screen size by creating a directory;
layout-large
My question is, can you create a directory that supports both? Something like;
layout-land-large
It's vital for a piece of work that a certain screen layout is displayed only on a tablet device in landscape mode, otherwise it's the default. If my solution isn't valid, is there another way to do this?
Thanks.
Change the folder name to: layout-large-land
This link explains how provide resources for different configurations:
http://developer.android.com/guide/topics/resources/providing-resources.html
Issue !!!
I need to develop an application for tablet (v3.1) in both portrait and landscape orientation.
I have placed the resources:-
For Portrait - Images in "drawable" and Layouts in "layout"
For Landscape - Images in "drawable-large" and Layouts in "layout-large"
Issue is that the landscape layouts are not picking the right images.
Can someone please help?
1.Create two main.xml files for layout in both case: landscape and portrait.
2.Put those two main.xml in resources according to its type:
/res/layout-land/main.xml
/res/layout-port/main.xml
Just build and try your application GUI in runtime.
or another example...
create only "layout-land" folder and copy paste your xml file.
/res/layout/main.xml
/res/layout-land/main.xml
layout-large is for devices with large screens, and also we have for example layout-small. the folder you need is layout-land, that the "land" part stands for landscape.
I think your layout folder should be renamed as layout-large-land or simply layout-land
The below snap is from Supporting Multiple Screens document.
Working as an .NET developer since I know myself and just bought an Android phone and think have to learn something new would not hurt me whatsoever, start reading one of those reference development books "Hello Android" and just read 50 page in a hour and like the system more than anything I know
Now I got a problem, under UI development topic it says I am able to develop two UI one for portrait and other for landscape besides, it says those two main.xml files are separated by their suffix so If I want to support two mode have to have two main.xml files one of them would be separated from other with -land suffix. But not able to create a new main UI with land suffix please could you show me how could I able to create a new main.xml with -land suffix under Eclipse. If you explain with screen shots it could be much more expressive.
Take a look at: http://developer.android.com/guide/practices/screens_support.html for reference.
But what you actually do is create a new folder under your res. Called layout-land for landscape layouts. And then have the layout main in that folder.
See this catalogue structure:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
the name of your landscape layout file will be main.xml, same as your portrait file, but it will be in the directory res/layout-land instead of simply res/layout where your portrait file will be. hope this helps and was simple enough without screen shots.
You need to create a folder layout-land in res folder and put the landscape main.xml in it