Different layout for orientation AND screen size - Android - android

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

Related

How to use tablet-specific layout when in landscape mode?

I have defined a tablet-specific layout in the res/layout-sw600dp folder. Now. It loads correctly in tablet emulator and is checked and managed by code as expected. The problem is that I cannot access this layout variant to use in mobile emulator after I check that orientation is landscape. When I type in code R.layout., no hint is given as to the specific tablet layout, only one instance is given, activity_main. How can I use that tablet layout in the landscape orientation as well?
./app/src/main/res/layout-sw600dp/activity_filter.xml
./app/src/main/res/layout/activity_filter.xml
The "smallest width" qualifier doesn't care about device orientation. You'll have to make a copy of your layout and put it in the res/layout-land/ directory if you want that same layout on phones in landscape.
If you don't want to have two exact duplicate layouts (one in sw600dp and one in land), you can look into using a resource alias: https://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters

Android Screen Orientation size

I have created various layout resource files in order to ensure that my app supports all screen and devices sizes.
My problem is which one of the below is suitable to use in my AndroidManifest file. Once the user switches the device to landscape I would like Android to choose the landscape resource file instead of portrait.
android:configChanges="screenSize|keyboardHidden"
android:configChanges="orientation"
Which one is more suitable to use?.
You just create One extra folder in your res folder named layout-land and put all landscape layouts in this folder then operating system automatic show the layouts according device orientation.
No need to add anything Manifest File.
Android system does it automatically. You don't need to put anything in your manifest.

Layout landscape mode and Categories of layout folders

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!

Defining a different XML layout depending on the device/screen size?

I have read lots of post on this forum and others about using a different layout depending on the device being used.
Below is a screenshot of my layout folder at the moment:
Now, I have tried many different variations to try and get the XML layout to change. The project is designed using a phone and I'm now testing on a 10.1 inch Samsung Galaxy tablet.
Despite all those layouts my app still uses the default .xml file.
Any ideas where I'm going wrong or other variations to try?
I should say I lock the user into portrait mode hence a few layouts with -port.
Any help would be great
thanks
You need to have your layout-large, layout-sw400dp-port,... folders at the same level as your layout folder instead of having them inside the layout folder.
Your folder structure should look like -
/res/layout/
/res/layout-large/
/res/layout-sw400dp-port/main.xml
...

Adding Separate Main for Landscape Mode

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

Categories

Resources