Supporting different devices with different layout - android

I have doubt in making the layout for other deices I mean to support different devices of different resolutions. I have made an application and it is working well on hdpi devices and I tested on Samsung Galaxy grand which has 320dp-460dp and 480px-800px.
May application is looking awesome on this device. but when I run on other devices its gone bad. SO I am suggested to make the folder like layout-large, layout-xlarge and layout-xxlarge but there is a lot of difference in this link and this link
So this makes me confuse , with which name I have to make the layout folders to support all devices ?? please tell me
and also tell me I have some hard coded values in my layout such as left margin 13 dp to make my design look perfect on hdpi device should I make it more in other xhdpi devices ???
and also which devices comes in layout-large folder and so on please answer my both confusion , thanks in advance

I use Google's code as an example of how to do stuff. The docs on "Supporting multiple screen" is a bit old and outdated. The best way to keep up with the current conventions is to follow other's codes.
Here is the source code for the Calendar app. Yes, there a lot of different folders for layouts/drawable/values but you have to consider the fact that there are a lot of devices with varying sizes and pixel densities.
Also, why do you want to make many folders for layout? You make a few layouts and let the values and drawables do the rest of the work. Hope it's helpful.

IF you are interested in knowing which device falls under which folder, then check this figure from the Official Android Guide:
Of course you need to know the actual size or density of the physical device

Related

Trouble with implementing app for different screens on Android

I am about to publish my first app and I am extremely confused about making it look nice on different screens.
At first I thought mdpi/hdpi/etc. values (dimensions) folders would suffice when I saw that the screen was showing the exact same things on S4 Mini & S6 Edge, hdpi & xxxdpi respectively.
Well, how is this even possible when I haven't specified other than the main dimensions.xml file?
From what I understand from playing with the layout editor on different devices is that screen size matters more (?).
So far I have created a mdpi/hdpi/xhdpi/xxhdpi folder but it seems that that's far from enough.
What other folders should I make? Do I need many layout folders too?
I would use this scalable size unit library. It's really easy to use and it will automatically scale your widgets for various screen sizes.
Here's the link if you are interested: https://github.com/intuit/sdp

How to create responsive design in android for any screen?

How can I size my application to fit all screens? ( from nexus 4 to nexus 6p)
I have created a folder layout-normal but it contains 3 phones, but I wanted something more specific.
Please help me.
The better way to support all different sizes is multiple layouts...
http://developer.android.com/intl/es/guide/practices/screens_support.html
All documentation help you about this. In text sometimes is better user small, Medium or High and not a sp.
But read the documentation and use
You can provide multiple resolutions for different resources, using different 'drawable' images, as shown at http://developer.android.com/guide/practices/screens_support.html
More information at this SO answer: https://stackoverflow.com/a/3263288/5127934

How to create layouts properly (Android)

i´m pretty new to android development and creating different layouts for each resolution wasn´t really that easy for me.
So, I was able to optimize my app for most devices (in eclipse), but i´m still having some problems here and there:
do I really have to copy the same images with different resolutions for each device-resolution into the respective folder? I´m currently using the hdpi, large-hdpi, mdpi and xdpi folders...
isnt it possible to use one drawable-folder and just scale the images down?
is there an extra drawable-folder for those 5.1in (WVGA)/5.4in (FWVGA) devices? In eclipse they´re labeled with mdpi, but these devices are using the large-hdpi folder and those images are too big, but perfect for i.e. nexus 7.
i´m also using 4 different layout-folders (layout-sw360dp, sw480dp, sw600dp & sw720dp). Is that a proper way to create a layout for each device-group?
Hopefully someone is able to help me with this.
Thanks in advance!
1) Yes you have to copy the images with different resolutions for each device resolution into respective folder. Because if you don't do that you will have unexpected results on different screen sized i.e. misplaced controls and layout will not be proper.
2) If you scale the images then they will get stretched or squeezed and you will not get proper result on the screen.
3) Folders sometimes behave differently on different devices. Sometimes they don't use the folders they are intended to use.
4) Yeah! as recommended in the documentation it is a good practice to use different folder as you can't be sure of the screen sizes in android.

Android layouts tree, human readable explanation?

If I write a message today is for getting details about the folder tree layouts in android.
I want to warn you now, I have read all the pages of the official documentation regarding support for different screen sizes, it is very complete, but in my opinion not really human-readable. So please, don't just copy a link to the documentation.
My question is simple:
What is the best combination of layouts folders to ensure maximum support for different screen sizes ?
Before Honeycomb, we had layout, layout-large, layout-xlarge, etc ... That's OK, but now we have sw600dp, sw360dp, sw ... Arggh stooop !
In my case, I have to make an application for android and I need to ensure maximum support.
I have some devices on hand:
Galaxy Note 10.1
Galaxy Nexus
Nexus S
Nexus 7
And ... Samsung Galaxy Spica (GT-5700)
And here are my layouts folder now:
layout
layout-sw360dp (for Galaxy Nexus)
layout-sw600dp (for Nexus 7)
layout-sw720dp (for Galaxy Note 10.1)
layout-480x320 (for GT-5700)
(and layout-*-lands)
I'm really not sure of doing things right, I thought the Nexus S would pick the layout folder, but it takes the layout-480x320, why?
So I have some questions:
1. Am I in the right direction?
2. Is it always necessary to create folders layout-large, layout-xlarge ... ? If so what should I put inside?
3. I do think the folder layout-480x320 is not a good solution, but I try to do things well and not make this folder is not enough.
Could someone tell me clearly how to do things right?
Thank you!
What is the best combination of layouts folders to ensure maximum support for different screen sizes ?
That is impossible to answer in the abstract.
Am I in the right direction?
-layout-WxH has been deprecated for a couple of years.
Is it always necessary to create folders layout-large, layout-xlarge ... ?
No. If you are not concerned about Android 2.x -large or -xlarge devices (e.g., Kindle Fire, NOOK) or Android 3.1 devices (0.4% of the market as of November 2012), then skipping -large and -xlarge is perfectly fine.
However, -small may still be relevant for you, for devices with very small screen sizes (under 3" diagonal), if you are supporting such devices.
I do think the folder layout-480x320 is not a good solution
Correct.
I try to do things well and not make this folder is not enough.
Then design a more flexible UI for -layout.

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