Inflate from layout-v10 folder on a hdpi gingerbread device? - android

I'm having both layout folders "layout-v10" and "layout-hdpi" in my application. However, as some gingerbread(which is API Level 10) devices also are hdpi screen size, the layouts under the "layout-hdpi" folder is getting inflated. I want to force the layout from "layout-v10" folder to be inflated for all gingerbread devices even if it is a hdpi. Is there any way to do so?
I read this link http://developer.android.com/guide/practices/screens_support.html couldn't figure out what can be done to solve my problem.

to keep layouts looking good in all devices we don't provide folders like "layout-hdpi", etc.
U need to keep your resources in drawable-hdpi, drawable-xhdpi, etc. as mentioned in the android developers guide. The android system chooses the correct folder based on the screen density. This works independent of the api version you are using, the layout will look good in all api levels if you are defining your resources correctly acc. to different screen densities.

Related

Android studio different screen sizes res folder

I have a question regarding android supporting different screensizes. I would like to know if it is necassary to add the different sw folder for example layout-sw24odp manually to support different dip modes. When I wouldnt add these folders would the application scale automatically in each device? Or do I need to provide the folder containing the layouts, to support different densitys?
It is only necessary if you are not getting the results you expect for a particular mode. In general I'll have separate folders for drawable-hdpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi and similar for layout- and values-, I'll only populate those if I have a layout that is not working the way I want on those devices.

Will layout folders fix the tablet compatibility?

I read a few things about how to make your app compatible with tablets. Some say about using your code and some say about the layout folders or some about the sw600dp and sw720dp folders. I am really confused and am not 100% sure which is the most simplest way to just make it play on a tablet.
What i did is i made 3 more layout folders (large, xlarge and small, I already had the drawable classes in all sizes but i didnt change the size of the images, its in all drawables the same size) and in these 3 extra folders i copied the same files i had in the plain layout folder. So i have 4 layouts with all the xmls the same.
Will this make it compatible with tablet and fix my issue?
for Xlarge use this folder drawable-xlarge-hdpi
for large use this folder drawable-large-xhdpi
layout-large (7 inch)
layout-xlarge(10 inch) folder are used for layouts
The Simplest way to make your app adopt to different hardware configurations is using folders. The framework will do all the work for you. (tutorial)

Eclipse problems with different Android Layouts

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)

How to make compatible an android app for multiple screen (Different size and different resolutions)

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

Android muliple screen 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)

Categories

Resources