What kind of tablets get under layout-xlarge and layout-sw720dp folders?
For example 8" - 10" goes under layout-xlarge folder. It's from documentation:
But what about layout-sw720dp ?
I know that If I haven't layout-xlarge folder android will navigate 10" tablet to layout-sw720dp, but what about 8" - 9" tablets ?
Android will choose layout or layout-sw720dp folder?
layout-sw720dp means devices with 720dp of smallest width. Specifically, the device's smallestWidth is the shortest of the screen's available height and width.
From Here
smallestWidth
Examples:sw320dp, sw600dp, sw720dp etc. The fundamental size of a
screen, as indicated by the shortest dimension of the available screen
area. Specifically, the device's smallestWidth is the shortest of the
screen's available height and width (you may also think of it as the
"smallest possible width" for the screen). You can use this qualifier
to ensure that, regardless of the screen's current orientation, your
application has at least dps of width available for its UI.
However if you use both layout-xlarge and layout-sw720dp in an app, the devices that qualifies both of them will always take from layout-sw720dp. This is because of the higher precedence for sw<???>dp qualifier. This is clearly specified in the docs which is linked above. If you have given multiple qualifier types for any resources, Android will search for qualifying folders in the order of precedences given to each type.
From the docs
Android supports several configuration qualifiers and you can add
multiple qualifiers to one directory name, by separating each
qualifier with a dash.
Table lists the valid configuration qualifiers, in order of precedence—if you use multiple qualifiers for
a resource directory, you must add them to the directory name in the
order they are listed in the table.
It will pick layout-sw720dp folder. According to screen width it will first look for device width larger than 720dp
The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. For example, layouts for an extra-large screen should go in layout-xlarge/.
Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the swdp configuration qualifier to define the smallest available width required by your layout resources. For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/. Using the new techniques for declaring layout resources is discussed further in the section about Declaring Tablet Layouts for Android 3.2.
Reference
https://developer.android.com/guide/practices/screens_support.html
There are multiple folder as bellow you can read about them aswell
1)layout-sw480dp drawable-sw480dp
2)layout-sw600dp drawable-sw600dp
3)layout-sw720dp drawable-sw720dp
Related
I'm working on android application and got in trouble of multiple screen support. I developed the app for 1080x1920 and when i tested the app on my friends Micromax Unite 2 with resolution of 480x800, it was something else. So i made two folders in the layout as:
layout-1080x1920
layout-480x800
thinking that the 480x800 device will pick up the layout-480x800 folder. But no it used the layout-1080x1920. So what should i do? So that the device having resolution of 480x800 works on layout-480x800
I suggest naming the folders as such:
layout-sw600dp
Where sw600dp means Screen Width 600dp. This layout folder will be used by devices with screen widths of 600dp or more (typically all 7-10 inch tablets, or just very dense screen). And when you are targeting for the phone use just the layout folder without any specified criteria. All phones not matching the sw600dp will use the default layout resources. Possibly also consider using
layout-sw600dp-port
if you need to use specific layouts for portrait orientation, likewise you can do
layout-sw600dp-land
if you wanted to specified layouts for landscape.
The link cricket_007 provided is where I learned this information
Note that 1080x1920 equates to about 540 x 960 dp in dp measurement, which is why I suggested to use the particular 600dp for width
giving the folder names pixel according to android screen support dev page. Even if you know all possible resolutions for every device, the android system takes those *xml files/drawables etc specified by their DPI, not PX. Those dpi resolutions still can change on runtime, such as, when your activity uses a tool bar (which is not part of your dpi resolution). Name your folders layout-xlarge, layout-large, layout-normal, layout-small for *xml layouts. I suggest to put 4 different xml files with same name in each of them and try it again for different devices.
I know how to use the following folders but for example I do not know what is difference between layout-small and layout-sw320dp?
Also, Suggest for me that which the folders are important to optimization.I do not like my program be seen for users as irregular.I want a final answer from you.
Based on which the folders I design my layouts? Because I have not multiple android devices to test the layout in different screen size.
I know how to use the folders and I have not problem about it.but my question is which the folders for continuous use and for all devices?
layout-sw320dp
layout-sw480dp
layout-sw600dp
layout-sw720dp
layout-small,
layout-large etc...
Both are qualifiers to define layouts for specific screen sizes.
Before Honeycomb - 3.0 (I guess), the screen's diagonal size was measured based in 4 groups: small, normal, large, and extra-large.
After that layout resources are defined for screen sizes with the smallest width (sw stands for smallest width).
Resuming, layout-small is deprecated and layout-swXXXdp qualifier should be used instead.
You can get more info about these qualifiers in Supporting Multiple Screen's Android official doc page.
The difference is that the qualifiers -small, -normal, -large had been marked as deprecated in API 13. Now the recommended way to go is using the -swdp folder structure. (see http://developer.android.com/guide/practices/screens_support.html#support )
The number of resources folders in your project depends basically on the type of devices you're targeting at (small phones, phablets, tablets, ...) and the number of different layouts you want to maintain. In most cases implementing a layout for landscape/portrait modes for phones and for tablets should be enough. Though you can create another layout for a specific screen size if you really need it.
Hope this helps.
It's 7' inch tablet.
DisplayMetric says:
DisplayMetrics
{density=1.0, width=480, height=752, scaledDensity=1.0, xdpi=160.0, ydpi=160.42105}
but the chosen resource folder for attrs.xml and styles.xml is
values-normal
but it should be:
large-normal
Is it correct or is it a bad configuration from the manifacturer?
As you can see, it is:
scaledDensity=1.0, xdpi=160.0, ydpi=160.42105
160 dpi corresponds to mdpi, not hdpi (240 dpi).
and mdpi is considered normal (so, the scale is 1.0).
But this is a TABLET.
I think it's time to use that damn
values-sw600dp
folder.
From the reference site:
Declaring Tablet Layouts for Android 3.2
For the first generation of tablets running Android 3.0, the proper way to declare tablet layouts was to put them in a directory with the xlarge configuration qualifier (for example, res/layout-xlarge/). In order to accommodate other types of tablets and screen sizes—in particular, 7" tablets—Android 3.2 introduces a new way to specify resources for more discrete screen sizes. The new technique is based on the amount of space your layout needs (such as 600dp of width), rather than trying to make your layout fit the generalized size groups (such as large or xlarge).
The reason designing for 7" tablets is tricky when using the generalized size groups is that a 7" tablet is technically in the same group as a 5" handset (the large group). While these two devices are seemingly close to each other in size, the amount of space for an application's UI is significantly different, as is the style of user interaction. Thus, a 7" and 5" screen should not always use the same layout. To make it possible for you to provide different layouts for these two kinds of screens, Android now allows you to specify your layout resources based on the width and/or height that's actually available for your application's layout, specified in dp units.
For example, after you've designed the layout you want to use for tablet-style devices, you might determine that the layout stops working well when the screen is less than 600dp wide. This threshold thus becomes the minimum size that you require for your tablet layout. As such, you can now specify that these layout resources should be used only when there is at least 600dp of width available for your application's UI.
You should either pick a width and design to it as your minimum size, or test what is the smallest width your layout supports once it's complete.
I'm trying to convert my application layout from the one for Galaxy to another for HTC Sensation.
I have created a folder layout-540x960 according to the screen size but i get this error: invalid resource directory name layout-540x960
How it can be solved?
Thanks,
Eyal.
You can't give a layout directory any name you want. Please read this article to find out how to support different screen sizes:
http://developer.android.com/guide/practices/screens_support.html
The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. For example, layouts for an extra large screen should go in layout-xlarge/.
Beginning with Android 3.2 (API level 13), the above size groups are deprecated and you should instead use the swdp configuration qualifier to define the smallest available width required by your layout resources. For example, if your multi-pane tablet layout requires at least 600dp of screen width, you should place it in layout-sw600dp/.
can anybody tell How to give layouts folder name to support multiple screen size in android
Thanks
From the documentation:
The configuration qualifiers you can use to provide size-specific
resources are small, normal, large, and xlarge. For example, layouts
for an extra large screen should go in layout-xlarge/.
Beginning with Android 3.2 (API level 13), the above size groups are
deprecated and you should instead use the sw<N>dp configuration
qualifier to define the smallest available width required by your
layout resources. For example, if your multi-pane tablet layout
requires at least 600dp of screen width, you should place it in
layout-sw600dp/.
res/layout– The default image folder
res/layout-sw200dp
res/layout-sw600dp
res/layout-sw800dp