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
Related
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!
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 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.
i added in manifest file.I craeted two folders layout-land and layout-port,eg:main.xml in both folder, i stored xml file in corresponding folder.when i change to landscape mode it is calling layout-port containg xml.
See http://developer.android.com/guide/practices/screens_support.html
Defined them as different layouts and put them in the appropriate folders and the os will handle it for you
You would be make different xml file as like drawable folders (landscape, portrait) as below :
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
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
If you are in landscape or portrait mode, Android looks for the layout file in either the -port or -land directory first, if it's not found then it falls back to the default layout directory.
Read more about resources here.
FYI the Android Emulator (AVD) isn't able to recognize it's in landscape. Even if you press CTRL + F11 and it turns the AVD emulator sideways, it doesn't actually register with the appliction that it's in landscape mode. So in short, if you're running on the emulator, your application will always think it's running in portrait mode (and not look for any "layout-land" resource folders). Test it on and Android device and it should work perfectly :)