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.
Related
I'm trying to create layouts for various screen sizes. I have used resource qualifiers to add sw600dp and sw720dp layouts, which work well with tablets in the emulator, but I want to make some specific layouts for foldable phones, starting with an 8 fold-out, which in device manager is said to have a resolution of 2200x2480, and displaymetrics confirms that the emulator has a screen width of 2200 pixels. I made a layout using qualifiers of w2200dp-h2480dp, but this is not used when I run the emulator (the sw720dp layout is chosen instead). I thought maybe the issue is using px instead of dp, so I've also tried w835dp-h945dp (as specified for a generic 8 fold-out device in the design preview window layout options), also w787dp-h837dp (derived from the formula dp = (px/dpi)x160 applied to 2200x2480), but none of these is used when I run the emulator.
How can I create layouts for this and other specific screen sizes? Am I going about it the wrong way?
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 am facing layout problem to support xhdpi and xxhdpi devices. As far as I know, android has no support for layout-xxlarge or layout-xxhdpi. Android use layout-xlarge to support both xhdpi and xxhdpi. For this reason, I am facing problem. Basically problems are two types. One is the top margin issues. Is there any way to set the top margin for both xhdpi and xxhdpi devices. I can't use LayoutParams or ViewGroup.MarginLayoutParams. The reason is I am using LinearLayout to define weightSum of children LinearLayout. Inside the children LinearLayout, I am using RelativeLayout for my layout.
The reason is that as of Android 3.2, the layout-xlarge, large, normal, small are all deprecated, and new identifiers were introduced, which you can find here Supporting Multiple Screens | Android Developers
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.
You should create dir with needed name like layout-xxhdpi
See http://developer.android.com/guide/practices/screens_support.html#NewQualifiers
I am developing an Android Application that supports all kind of Android devices like mobiles and tablets. But it's time consuming to create multiple folders (small, normal, large and xlarge android xml layouts) to support all the Android devices. Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc?
You only need to create unique layouts (ie. *layout_mdpi* ) if you want something unique for that particular screen size.
If you want to use the same layout on all different screen sizes, you will only need to create a single layout (in the layout folder).
Only if you want to customize a particular layout would you need a new FOLDER in layouts (named: layout_mdpi) in that folder you would have multiple copies of customized layout with same name (ex. my_layout.xml)
To clearly answer your question - you will only need the layout folder and no other ones in your casel
Ex.
res\layout\my_layout.xml // this folder is all you need if this layout will work on all screen sizes
res\layout_mdpi\my_layout.xml // you ONLY need this if you are presenting something unique on this screen size.
In Android we need to maintain different folders for the layouts with different resolution reason behind it is the use or the resolution of the Android Device on which the application gonna execute.
small Resources for small size screens.
normal Resources for normal size screens. (This is the baseline size.)
large Resources for large size screens.
xlarge Resources for extra large size screens.
Android OS select the specific layout it self by checking the compatible device and its resolution.
So, better to create folders to support in multiple screens
For More Info refer this
Is there any way to build an android app that runs on all android devices without creating these folders:small, normal, large, xlarge etc
Consider this, you have a button (with match_parent) that stretches full width of a screen in portrait mode of a 4 inch phone, that's fine it looks alright, but then that same layout on a 10 inch tablet in portrait is now 3-4inch wide, that's not great looking.
"So what" you say, make it wrap content, okay then so the button now only fills up part of the width on phone, still looks okay but then on a tablet you have huge amount of space now either side of the button, maybe that's looks okay, maybe not.
Maybe same button on a smaller screen takes up too much space?
Now apply the above to every single layout element in your app.
Do you think it'll look good, using the same layout, do you think your users will be okay with an app that was so little care to its UI and UX?
SO, in conclusion, yeah it's possible to only use one eg normal, for all devices but it'll probably look terrible on most of them.
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/.