If I write a message today is for getting details about the folder tree layouts in android.
I want to warn you now, I have read all the pages of the official documentation regarding support for different screen sizes, it is very complete, but in my opinion not really human-readable. So please, don't just copy a link to the documentation.
My question is simple:
What is the best combination of layouts folders to ensure maximum support for different screen sizes ?
Before Honeycomb, we had layout, layout-large, layout-xlarge, etc ... That's OK, but now we have sw600dp, sw360dp, sw ... Arggh stooop !
In my case, I have to make an application for android and I need to ensure maximum support.
I have some devices on hand:
Galaxy Note 10.1
Galaxy Nexus
Nexus S
Nexus 7
And ... Samsung Galaxy Spica (GT-5700)
And here are my layouts folder now:
layout
layout-sw360dp (for Galaxy Nexus)
layout-sw600dp (for Nexus 7)
layout-sw720dp (for Galaxy Note 10.1)
layout-480x320 (for GT-5700)
(and layout-*-lands)
I'm really not sure of doing things right, I thought the Nexus S would pick the layout folder, but it takes the layout-480x320, why?
So I have some questions:
1. Am I in the right direction?
2. Is it always necessary to create folders layout-large, layout-xlarge ... ? If so what should I put inside?
3. I do think the folder layout-480x320 is not a good solution, but I try to do things well and not make this folder is not enough.
Could someone tell me clearly how to do things right?
Thank you!
What is the best combination of layouts folders to ensure maximum support for different screen sizes ?
That is impossible to answer in the abstract.
Am I in the right direction?
-layout-WxH has been deprecated for a couple of years.
Is it always necessary to create folders layout-large, layout-xlarge ... ?
No. If you are not concerned about Android 2.x -large or -xlarge devices (e.g., Kindle Fire, NOOK) or Android 3.1 devices (0.4% of the market as of November 2012), then skipping -large and -xlarge is perfectly fine.
However, -small may still be relevant for you, for devices with very small screen sizes (under 3" diagonal), if you are supporting such devices.
I do think the folder layout-480x320 is not a good solution
Correct.
I try to do things well and not make this folder is not enough.
Then design a more flexible UI for -layout.
Related
I have doubt in making the layout for other deices I mean to support different devices of different resolutions. I have made an application and it is working well on hdpi devices and I tested on Samsung Galaxy grand which has 320dp-460dp and 480px-800px.
May application is looking awesome on this device. but when I run on other devices its gone bad. SO I am suggested to make the folder like layout-large, layout-xlarge and layout-xxlarge but there is a lot of difference in this link and this link
So this makes me confuse , with which name I have to make the layout folders to support all devices ?? please tell me
and also tell me I have some hard coded values in my layout such as left margin 13 dp to make my design look perfect on hdpi device should I make it more in other xhdpi devices ???
and also which devices comes in layout-large folder and so on please answer my both confusion , thanks in advance
I use Google's code as an example of how to do stuff. The docs on "Supporting multiple screen" is a bit old and outdated. The best way to keep up with the current conventions is to follow other's codes.
Here is the source code for the Calendar app. Yes, there a lot of different folders for layouts/drawable/values but you have to consider the fact that there are a lot of devices with varying sizes and pixel densities.
Also, why do you want to make many folders for layout? You make a few layouts and let the values and drawables do the rest of the work. Hope it's helpful.
IF you are interested in knowing which device falls under which folder, then check this figure from the Official Android Guide:
Of course you need to know the actual size or density of the physical device
I am having some problems with layouts in my android application. I have created multiple android resource directories, for multiple android devices. The problem stands when I try to test my app on a nexus 5 emulator the screen's layout is out of bounds, it is disproportionate completely. In my app all the layouts for the layout-xxhdpi-1080-1920 seem completely alrigth, the problem arises when I start my app in an nexus 5 emulator. It seems that the emulator picks a different layout size and not the one is it supposed to.
And I also have one question reqarding layout creation. Is the any better way to cover as much android devices as possible, instead of making all layout resolutions: for example: -mdpi-460x800 , xhdpi-720x1290, xhdpi-1080x1920, and so on ... It really takes about more than 18 layout directory types and it is quite a lot.
I already looked at all the documentation Supporting different screens.
You could cover almost every android device in the world. To do this you need have device specific resources.
for android versions earlier than 3.2
layout-ldpi
layout-mdpi
layout-hdpi
layout-xhdpi
for android version 3.2 and higher
layout-sw360dp
layout-sw420dp
layout-sw600dp
layout-sw720dp
This is just an representative example, more information here in android docs
Okay i am familiar with this site and what it says
http://developer.android.com/guide/practices/screens_support.html
But im still having a problem.
I am designing layouts for phones and tablets from gingerbread to jelly bean.
I had started with a basic layout folder and designed everything for a galaxy nexus phone. now im going back and adding tablets. one question here is should i use layout-xlarge/layout-large or layout-sw600dp/layout-sw720dp? im guessing the smallest width is what i should be using.
But thats not the issue.
This issue is im trying to do that layous for Galaxy Nexus (720x1280) and Nexus S (480x800) These are much different yet eclipse doesn't seem to let me differentiate.
So i just want to be clear on what i should be doing to do this right. is this what i should have to cover the devices i want to?
layout-hdpi
layout-xhdpi
layout-sw600dp (instead of layout-large)
layout-sw720dp (instead of layout-xlarge)
will doing those layout-hdpi and layout-xhdpi separate the layouts for a Nexus S and Galaxy Nexus?
First, the layout-sw are based on dp, Density-independent pixels, rather than pixels. You can think of dp as 'actual size' pixels i.e., 1dp is the same physical size no matter what device is being used.
Therefore the Galaxy Nexus, which has a 720x1280 pixel screen is only 360x640 dp resolution and there is no overlap between a phone and the higher sw600+ folders.
The large/xlarge buckets will continue to work on all tablets, but if you need finer grained support or alright only using tablet layouts on Android 3.2+ devices, then you only need the sw--dp folders. You can also use both without copy/pasting your XML by using a reference file, as detailed in the below blog post.
More details on how to support multiple screens can be found in Supporting Multiple Screens guide and some of the reasoning behind why you'd want to use the new sw---dp buckets can be found on the Android Developers blog post announcing the feature.
Just use layout-large and layout-xlarge. When you're developing the layouts and want to know what it looks like on a certain device, just change the view and it will pull the appropriate XML from the correct folder.
I have created layout files for small, large and xlarge screens sizes, but when I load my app on a Samsung S3 emulator, with the resolution of 720 x 1280 it is still the default layouts which are being used.
I do not understand why android is not using my specific layout files.
I have placed the layout files in the folders layout-large, layout-small, layout-xlarge under the folder layout.
Hope someone can point me to what I am doing wrong.
Thanks.
The screen size buckets you are referring to are deprecated since Android 3.2 (API level 13?). If you are targeting later versions of Android then you should be using the "smallest width" qualifier to enable a finer grain control.
The Samsung Note for example will leverage the old "layout-large" bucket but it doesn't respond well to mini- or normal tablet layouts. These devices are normally running Android post 3.2 (the DELL Streak and original Galaxy 10.1 tab are the exception). To differentiate in this instance supply a layout-sw520-port and layout-sw520-land resource folder and place the layouts here. Further differentiations can be made for Nexus7 type devices (sw600) and so on. Note there are reserved pixels on screen (notification/action bar etc) so the physical smallest width DPI is not precisely what your layout will respond to (albeit predictable close).
Diana Hackborn (hackbod) wrote a comprehensive blog post on the subject describing the motivation s behind the change and the sorts of problems (cf. Your issue) it solves. Google have also put together some advice on designing for multiple configurations as part of their tablet drive. Have an Android Dev Guide trawl should you hit further issues.
Samsung S3 is in the "normal" category.
What I found helped me greatly to get layouts which scales to different resolutions was layout_weight="1" and layout_width="0dp", just in case someone drops by this question wondering why there layouts do not scale in some areas.
I've tried to run my app on a Nexus-One-like emulator skin and a Galaxy-Tab-like. As far as I know, both devices are hdpi, but Nexus is considered large and Galaxy Tab is considered xlarge. I have two folders for my drawables: drawable-large-hdpi and drawable-xlarge-hdpi. However, Galaxy Tab takes resources from the drawable-large-hdpi folder. It does not make sense for me. Am I doing something wrong? How can I manage my resources to fit on both screens? Thanks.
Two things, you are probably wrong in saying Galaxy tab is xlarge, from my memory I had found it to be large screen, check this. Second, read up here to learn more about this. Trust me it can get really messy and hard to remember :)
A 7" screen can be either Large or XLarge according to http://d.android.com/guide/practices/screens_support.html
For the Galaxy Tab, it appears to be considered Large.
The problem could also be that, Android 2.2 does not have the XLarge qualifier, so it fails into Large by default. That qualifier was introduced in Android 2.3. I do not think 2.3 has been rolled out to the Galaxy Tabs yet, so it's possible the resources may change with an updated version.
This is probably a little late, but better late than never I guess.
The 7 inch Galaxy Tab is considered "large". If AndEngine is not picking up your resources correctly from the "drawable-large-hdpi" folder, then it is likely to do with your AndroidManifest.xml. Check to make sure that you have a "supports-screens" tag, and the "large" attribute set to true. Example:
<supports-screens android:large="true".../>
You will probably need other attributes set as well (e.g. "normal") to support phones. As a fallback, also enable "anyDensity".