Android support screen design - android

I know about supporting multiple screens in Android and I use it in my app. But supporting different screen sizes and DPI makes your application size large. We all know about the 50mb file size limit in Google Play right? So, is it possible to create a folder like the following?
\layout-small-160
\layout-normal-240
If that is not possible do any one here knows how to support multiple screen sizes and its DPI's without using too much image to make my application size smaller?

I only give my suggestion and you can try it.
By default, we have three drawable folder drawable-ldpi(120), drawable-mdpi(160), drawable-hdpi(240).
When the App need image, Android will find the image according to the screen destiny. Obviously, the image in drawable-ldpi folder is fit if the app running on phone which have a low destiny.
But if there is no image in drawable-ldpi folder. Android will find if there is image in drawable-hdpi. If it exists, android will scale the image(0.5) and show it.
So you don't need to prepare images for every destiny. You only need to prepare the image for hdpi scrren. And for some individual images which demand accurate size, you need to prepare for the three destiny.
You could download some famous APK and extract them.Then enter the res folder to check how the author did.
Sorry for my poor English.

From Supporting Multiple Screens article of Android documentation:
To optimize your application's UI for the different screen sizes and densities, you can provide alternative resources for any of the generalized sizes and densities. Typically, you should provide alternative layouts for some of the different screen sizes and alternative bitmap images for different screen densities. At runtime, the system uses the appropriate resources for your application, based on the generalized size or density of the current device screen.
Therefore, yes it is possible to create folders for different layouts as you mentioned in your question. The following is a good practice of having your resources folder organized for different screen sizes and different bitmap drawables:
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
Yet, you do not need to provide alternative resources for every combination of screen size and density. The system provides robust compatibility features that can handle most of the work of rendering your application on any device screen, if you develop your application following the instructions described here.

2 suggestions:
Resize the images to be exactly the size you need. Use proper compression (use a professional application to edit the images, like photoshop, that optimize the image and compress it well).
Put part of the images on an external server and download all on the first use. Downloading the images from the server has the advantage that you know the device size, so you can download only the relevant sizes.

Case close.. It is posible to create a folder that has two modifier..
like this
layout-normal-hdpi ---- this will only set the view from specific phone that has 240 dpi and normal screen
thanks for all who commented and give an idea here..

Related

android multiple screens compatibility

I read info about "Supporting Multiple Screens" and other post here... but Im really confused about how can I develop my application that run on multipple devices.
I was starting develop on a determinate screen (normal size layout), then I run my apk on a S4 galaxy so I see that every object of my apk was diferent size to my xperia to the S4.
what I need to do to make my apk compatibility for all the devices?
I read information that the only source to make that is:
res/layout/my_layout.xml // layout for normal screen size
("default")
res/layout-small/my_layout.xml // layout for small
screen size
res/layout-large/my_layout.xml // layout for large
screen size
res/layout-xlarge/my_layout.xml // layout for extra
large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra
large in landscape orientation
For:
res/drawable-mdpi/my_icon.png // bitmap for
medium density
res/drawable-hdpi/my_icon.png // bitmap for high
density
res/drawable-xhdpi/my_icon.png // bitmap for
extra high density
is this true? so I need to make different layouts for different devices?
guys please help me with this issue cz I relly dont understand how is the deal for multiple devices compatibility.
For the layouts:
You can most likely get away with one set of layouts for your application. By default, Android's gui system is done in such a way that you should be able to make good use of the screen of any device, for example use layout_weight and specify things in dp (density-independent pixels). By providing only one layout though, you're most likely going to have it optimized for phone or tablet sized screens. If you create it for phones, then tablets will probably have a lot of empty space, whereas creating another set of layouts would allow you to put extra info on the screen than the phone layouts could fit. It depends how willing you are to customize your app experience for each users device. To create multiple layout, it's recommended to use the Android 3.2 size qualifiers. For tablets, you could use res/layout-sw600dp. See here under "Using new size qualifiers".
For the drawables:
You will most likely not want to have just one set of drawables. You can, and the Android system will scale all your drawables to maintain the same physical size on all screen sizes, but due to scaling, the images will not look very good. That's why you provide an image that will look good for each "category" of screen density, and the Android system will choose the one for that device's screen density, and any scaling it has to do will be minimal.
It is kind of confusing at first, but you most likely don't have to worry about the layouts specifiers just yet. I would make sure to read the supporting multiple screens article and writing your xml layouts such that they make use of the screen size in a relative way.
Have you read this page? Or this one?
You create resources with duplicate names located in folders that are qualified a certain way. At runtime, the system will choose the resources that best match the current configuration of the device. If you want your device to work on multiple screen sizes and multiple screen densities, you will need to create different resources (layouts, drawables, etc) and qualify them appropriately.

Android layout on high density displays

i just released my app on android and have problems with customers with high density displays.
i added a debug thing to see what's going in, here is one sample output
Device: Nexus 10 Android version: 4.2.2
DisplayMetrics{density=2.0, width=2560, height=1504, scaledDensity=2.0, xdpi=298.275, ydpi=298.823}
MainView w=1900 h=1342
mDrumKitMode=BIG
KitView w=640 h=1266 x=1920.0 y=0.0
the main view is the music notation area on the left of the screen shot, its 1900 wide (MainView w=1900 h=1342) the drum kit is a bitmap that is 640w and 640 high. somehow, the display is scaling it to be full height of the parent, (KitView w=640 h=1266 x=1920.0 y=0.0). this doesn't happen on displays where density=1.0.
i have no way to test this since i can't get the emulator work on big displays for some reason and i don't have a high density tablet.
does anyone have an idea what could be going on? thanks
and here's another customer with a similar problem
Device: A700 Android version: 4.1.1
DisplayMetrics{density=1.5, width=1920, height=1128, scaledDensity=1.5, xdpi=224.73732, ydpi=224.11765}
MainView w=1260 h=1044
mDrumKitMode=BIG
KitView w=640 h=968 x=1280.0 y=0.0
i think its the scaledDensity=1.5 parameter, maybe i need to do something to disable automatic image scaling, i.e. set scaledDensity=1?
i should add that the entire application is based on exact pixel positions, both for the music notation display and the drum kit display which overlays images on top of the base drum kit image (you can see the drum pedals are in the wrong place on this image too). i don't want automatic scaling as i handle scaling inside the app for different display sizes and user preferences.
i should also add that all my drum kit images are in drawable-mdpi and all the other dpis are empty. this is because i scale images programmatically based on screen size and user preference BUT i think maybe the problem is a need to put some images in xhdpi? i guess i can do that but it will be a lot of work.
PS, i guess i found my answer here http://developer.android.com/guide/practices/screens_support.html
Provide different bitmap drawables for different screen densities
By default, Android scales your bitmap drawables (.png, .jpg, and .gif files) and Nine-Patch drawables (.9.png files) so that they render at the appropriate physical size on each device. For example, if your application provides bitmap drawables only for the baseline, medium screen density (mdpi), then the system scales them up when on a high-density screen, and scales them down when on a low-density screen. This scaling can cause artifacts in the bitmaps. To ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
i wonder if simply copying all the -mdpi images to -xhdpi will work?
If you intend for this app to be used across devices you have no choice but to put in images for all the various density folders that exist (xhdpi,xxhdpi, hdpi, mdpi). It's also worth considering that you may want to change the actual layouts you include, to offer different ones for different devices.
Consult the documentation for how to handle this.
http://developer.android.com/guide/practices/screens_support.html
If that creates an apk that's too heavy (I have no idea how many images you have) then you can go the other way and specify a no scaling drawable folder which will just use the images in their native density across devices. It's definitely wrong to use ONLY mdpi unless you intend to support only mdpi devices.

Handling image resource size on Android

I am kind of confused about managing graphic resources in Android.
Tried to read this doc but It only confuses me more. Can anyone give me some example of how should I handle the following case?
Lets assume that I have an image in my layout that will be scaled to fill screen width. What image sizes (in pixels) should I produce and what configuration qualifiers (drawable-{qualifier}) should I apply to those resources to cover all major dpi and screen sizes (both for tablet and handset)?
Thanks.
If you want to have an image, that is supposed to fill the screen it is best to use 9-patch images. This way your image can automatically scale to fit the device. Because even if an image has the correct density, the actual screen size can vary. For example a smartphone and a tablet can both be hdpi, but have completely different screen sizes (and actual pixel count).
So the easiest way to target most devices, when it comes to images that are supposed to fill up the full width of the screen is to have a 9-patch image and create ldpi, mdpi, hdpi and xhdpi versions of it. This way the image will automatically be choosen depending on the density and then stretched to fit the device.
The android sdk also provides a tool that helps with creating 9-patch images http://developer.android.com/tools/help/draw9patch.html

What resolution reference to consider for making images for android games?

I want to make a game which can work on all screen resolution and size. In order to begin making the game, what screen resolution should I consider for making graphics? I have seen that that the angry birds game has only a single image for all screen resolution, so what base resolution do they consider for making graphics? Next with that base what calculation do I have to do in order to scale those images for other resolution?
If you are targeting multiple device in android then you need to use different image for your game need to use in android project.You can make your Android project Structure like below for all devices
Here is Your Structure of Resource Folder in android Project
1.res/drawable for Default Images
2.res/drawable-hdpi for high-density // bitmap for high density
3.res/drawable-hdpi-v5
4.res/drawable-v9
5.res/drawable-ldpi
6.res/drawable-ldpi-v5
7.res/drawable-ldpi-v9
8.res/drawable-mdpi // bitmap for medium density
9.res/drawable-mdpi-v5
10.res/drawable-mdpi-v9
11.res/drawable-xhdpi // bitmap for extra high density
Now For Layout Structure is below :
12.layout This Use For Default Layout Files // layout for normal screen size ("default")
13.layout-land For Use in Landscape Mode
14 layout-large // layout for large screen size
15.layout-large-long
16.layout-large-long-land
17.layout-large-notlong
18.layout-large-notlong-land
19.layout-ldpi
20.layout-normal-long
21.layout-normal-long-land
22.layout-normal-notlong
23.layout-normal-notlong-land
24.layout-small // layout for small screen size
25.layout-small-land
26.layout-xlarge // layout for extra large screen size
27.layout-xlarge-land // layout for extra large in landscape orientation
According to your requirement you can add image in res/drawable that used for ldpi,mdpi,hdpi,xhdpi same for layout file .Also you can refer this SO link .SO Link

fullscreen images and android resolutions

I have a game which displays a full screen image in the background. At the moment I have one image size (1280x800). This works well on large resolutions but on smaller screens the shrinking somewhat degrades the image. You can see jagged edges and it is noticeably worse than what you could achieve using photoshop software.
I have different image sizes, but I am unsure how to utilize them. I know there are different dpi folders, but you can have resolutions of 480x320 and 1280x768 with the same dpi so I don't think these can be of use here.
I believe you can have different layout files for different screen sizes, but the image is not drawn using xml (and in fact would not be possible for my game).
I can only think that I must create a different file name for each size. Then when choosing which image to use I could take the screen dimensions and select the correct one? I am struggling to see how I can make an image look good on both 240x320 and 1280x800 resolutions.
All of the resource qualifiers in the framework can be applied to drawables, not just the dpi designators. In other words, you could create folders like this to segment your images as well:
drawable-ldpi
drawable-xlarge
drawable-normal
drawable-sw480dp
drawable-sw720dp
Even examples like these work...
drawable-v10
drawable-land
And so on...
You can create as many or as few different qualified directories for your image assets as you think necessary to preserve the quality. The Supporting Multiple Screens article in the SDK docs helps describe most of the qualifiers that best fit scaling image assets.
HTH!

Categories

Resources