I created a special layout for one of my activities in the /layout-small folder. The problem is that when I open my default layout (the one for which I have the small version), Eclipse decides to open the small version instead! At this point I go back the 'normal' layout but it's displayed for a 2.7" screen and if I make any change to visualize it in any other screen size Eclipse decides to send me to my 'small' layout while keeping the default one at 2.7". I can change my small layout to any size I want but that really makes no sense at all!
Any help is appreciated. Project CLEAN and restarting Eclipse I already tried.
I also had your problem for managing different screen sizes. The one that I use most frequently is to reorganize my layout folders in the same order as drawables. By this I mean that I create these folders for layout :
layout-ldpi
layout-mdpi
layout-hdpi
layout-xhdpi
If you open a layout file from the "layout-hdpi" folder , the default device for displaying the preview will be an hdpi one , like "4.0 480*800 hdpi".
Also. I found it much more time-consuming when adapting to different screens.
Another workaround that I'm really in favor of, is using the Intellij Community Edition for android development and user interface design. Intellij is a very stable and robust IDE based on gradle and is much much smoother than the buggy Eclipse.
If you are still having layout issues then I suggest reading this:
http://developer.android.com/guide/practices/screens_support.html
As of API level 13 layout-small/normal/large have been deprecated and you should be using sw<>dp qualifiers.
I have an app that has multiple layouts and my standard layout file is for screens that have the smallest available width like so:
layout (smallest screens)
layout-sw480dp (screens that are slightly larger)
layout-sw600dp (7" tablets)
layout-sw720dp (10" tablets)
Related
I have been working with programmatic layout in Android Studio and i have a problem:
AVD always uses normal layout even if i use Nexus 7 which has "large" screen as its property
it is not code problem, since when i plug in my tablet it uses large layout and works fine
Any ideas where the problem might come from?
Well you are right in some sense android should take layout dependent on different densities but some mobile do not fall under specific density. Therefore android will pick up default layout from layout directory.
to support multiple screen resolution provide different layout for different screen sizes, you can make following directories in res directory like this
layout-hdpi
layout-mdpi
layout-xhdpi
layout-xxhdpi
layout-w320dp-h408dp
layout-w480dp-h800dp
layout-w480dp-h854dp
layout-w720dp-h1280dp
layout-w1080dp-h1920dp
layout-w1440dp-h2560dp
when you provide layout in all this directories you will give multiple screen support for different sizes as well
Eclipse has provided us with different qualifiers like size, ratio , etc. So when I select a qualifier, it provides us with the right emulator screen to make our layout. But are these emulators screen loaded under the right layout folder? I dont understand, how Nexus 10 which is a xlarge screen size is loaded when I load the activity_main under the Normal layout folder?
am I blindly arranging these layouts? Because before this, I had arranged all layouts perfectly and when I went to run it on a Virtual Device, it looked a complete mess. I looked at the xml files and they were completely in the wrong places.
I have used qualifiers like : normal-long, normal-notlong, large-long, large-notlong, small-long, small-notlong, xlarge-long, xlarge-notlong,
Should I change the qualifiers? Please suggest.
This seems to be some kind of a bug in eclipse, with layout-large etc not being used much now.
I would advise you to try using smallest width qualifiers.
also, if you would like more accurate emulation, you could look into genymotion emulators
http://www.genymotion.com/
I had the same problems. I use the layout-normal, layout-small/-large etc. These folders though are deprecated and android recommends using the swdp like layout-sw600. I still use the small/normal/large/xlarge folders but eclipse had a bug which caused the wrong display to open for normal layouts. Updated my adt plugin fixed it for me
I am developing an Android application in portrait view only. This is working fine for 320 * 480 resolutions in all android versions (Version 2.2 to 4.2).
Now I want to support this application for the following resolution too:
960x540
480x800
1280x720
What will be the best approach to support my application for multiple screens.
I have 3 types of images: 1x, 1.5x and 2x.
In 320 * 480 resolutions I am using 1x images.
I searched a lot but still not clear what approach will be the best and right approach.
I have few options:
Use a single layout (under res/layout) and separate drawables (under res/drawable-mdpi, res/drawable-hdpi and res/drawable-xhdpi) for each resolution.
Using separate layouts (under res/layout, res/layout-large and res/layout-xlarge) and separate drawables (under res/drawable-mdpi, res/drawable-hdpi and res/drawable-xhdpi.) for each resolution.
Or any other best approach which should be always used whenever support multiple screens.
Onr more problem: When I am using any one above approach, my changes are not appear on hdpi and xhdpi screens.
Please guide me. Thanks in advance.
There is no single right way, I believe this decision depends of your application.
In apps with clean layouts, I make an unique xml_layout, and I use android:layout_weight to distribute the elements on the screen. Thereby, I get a similar distribution of this elements on the space available, in the all different screen resolutions.
Otherwise, when the layout is more complex, it's necessary to create different layouts to support the different screens.
The best option is 2, and it is the Android standard, recommended way of providing resources.
And I think your problem is due to you did not specify the correct type. For layout alternatives, you can also use:
layout-h720dp
layout-land
layout-sw600dp
layout-sw600dp-land
layout-sw720dp
layout-w720dp
Please refer to http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
I have developed an android application and run it on an HVGA emulator. It's running successfully on any HVGA device i.e. mdpi. But if I try to run on small screen resolution devices i.e QVGA then my buttons are looking as if they go down and dont fit onto the small screen...
So how can I run my android application on multiple screen resolution successfully?
follow these instructions
create a folder in yourAppFolder/res/ named layout-small (*more on this subject later)
insert in this folder all your xml layout items that need special treatment for a small screen (it is not necessary to copy all of "normal" layout files, but you can if you wish)
change the files in this layout as needed
What happens with this approach:
if the device has a non-small screen, the default layout (the one in "layout" folder) will be loaded and used, otherwise if the screen is in "small" category the files in "layout-small" will be used instead (only if one with the same name is available, otherwise the one in "layout" will be used
*About folder naming: that policy was the old one supported by android. Nowadays there is another one, more precise but more complex too (example: specify minimum necessary width). Anyway, this is still supported, just note that eclipse may suggest you some alternatives. Currently, i am still developing with the old naming policy.
I think it is better to design your layout for every screen size and resolutions. It is easy in android. Copy your layout from "layout" folder of resources and paste it in the "layout-land", "layout-xlarge", "layout-xlarge-land" and ... folders and change those settings you need in them.
you can check this link:
In the UI builder (part of the Eclipse plugin), you can build your interfaces for multiple screen sizes and resolutions. To make different layouts for different resolutions, simply follow these instructions to build alternate layouts:
http://developer.android.com/guide/practices/screens_support.html#support
I have to design an application which to support under three resolution. for that i use the code in manifest
and also create three folder layout , layout-large, layout-small for supporting three resolution, correspondingly i put the different resolution of image in drawable-hdpi ,drawable-ldpi ,drawable-mdpi , but whenever i run the app in different resolution it going to take low resolution image instead of different resolution i use.
I don`t know where i made the mistake, whether i have to add some code in layout xml or not. I also search the android developer forum and i do the application design as they insist.
Any one suggest some idea to achieve this.Thanks
There are two things you could check: have you set the minimum SDK version of your app to use version 4 (Android 1.6) support for this started?
Secondly, the layout-large and layout-small folders are designed for different sized screens (think tablet vs phone), and not resolution. If you're changing the resolution (DPI) of the device, you'll need to use layout-hdpi, layout-ldpi etc.
Further, if it's only the images you're changing, you should be placing the different images in drawable-hdpi, drawable-ldpi etc, and not layout-xxxx. If on a supported device, Android will pick the image from the correct folder, so you'll only have one layout folder (or 2 if you use layout-land)
Some (or all :S) of these points are covered in this link, to another question on StackOverflow. Try to use the search function before asking a question. Also, you'll find people are more receptive to providing answers to users with higher accept percentages.
Android - layout-large folder is been ignored
Edit: for multiple screen support, also look at Fragments to better organise and fit your content for both large and small screen devices (dev.Android, worked example)