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/.
Related
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
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.
I'm implementing an application and I want to support all screen sizes. I have 4 layout folders: layout, layout-small, layout-large and layout-xlarge.
Which screen size supports the standard layout folder? Is it even necessary?
Which screen size supports the standard layout folder?
In your case, it will depend on what files are in what directories.
Let's say that you have main.xml in layout/, and not in any of the other three candidates. Then, setContentView(R.layout.main) will use the copy in layout/.
Now, let's say that you add a revised version of main.xml in layout-xlarge/. On an -xlarge device, Android will use the layout-xlarge/ version of main.xml, and on other screen sizes, Android will use the layout/ version of main.xml.
Now, let's say that you add a third main.xml version, this time in layout-small/. Android will still use the layout-xlarge/ copy of main.xml for -xlarge devices. However, all other devices will use layout-small/, and the layout/ copy of main.xml will be ignored. Android will not try to shrink a layout from a larger size (e.g., -xlarge layout on a -normal device), but it will try to expand a layout from a smaller size (e.g., a -small layout on a -normal device).
What I tend to do is use layout/ for:
Layouts that do not need different versions for different sizes
Layouts to be used on -normal devices (as I rarely support -small)
I then use layout-large/, layout-xlarge/, or their Android 3.1+ replacements (e.g., layout-w720dp/) for layouts to be used on larger screen sizes.
However, that is just my particular style, and you are welcome to do what you want, within the usage rules described above.
using modern notation is a better solution:
/layout // for phones
/layout-sw600dp // for 7 inch tablets
/layout-sw720dp // for 10 inch tablets
In popular:
Mdpi screen smartphone is cheap
Hdpi screen smartphone is expensive.
If you use layouts only mdpi folder, this layout will be used for all screens
Legend:
layout-small = ldpi
layout = mdpi
layout-large = hdpi
layout-xlarge = xhdpi
Not supported on Android Studio. I want to create a layout new phones, like Galaxy S4. I have one to test on and the sizes are too small. But android studio compiler gives an error, because that forward slash is appearing. I tried layout-xxlarge, it give an error too.
android-apt-compiler: [xxxxxxxxxx] invalid resource directory name:
C:\Users\xxxxxxxxxxxxxx\Dropbox\android_studio_workspace\xxxxxxxxxxxxxxxxx\res/layout-xxlarge
Are these layouts supported on Eclipse?
As you can see here, section "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 best you can get is:
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
The ones you need are defined here.
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