Reputation: 249
I want to optimize my application for all screen sizes. Now I wondered if i really have to put it all into one apk. These are the screen sizes i want to support:
320x480 400x800 400x852 540x960 720x1280
I think there are so few devices that have the 240x320 resolution that the effort would be to high to support them too. So my question is, whether i have to put in each density folder all images?
Another problem: I want to offer my application up from 2.1, but 2.1 does not support xhdpi screens, such as 720x1280, respectively 2.1 cant get along with these large images.
Upvotes: 1
Views: 1106
Reputation: 1699
I would state another solution from android development strategies that I am very fond of.
Another approach is to start with the device with the largest screen size, and then scale down and figure out the UI compromises you'll need to make on smaller screens.
from http://developer.android.com/guide/practices/screens_support.html
So create one drawable
folder with images designed for the maximum density. Currently 10 inch tablet and scale it down.
Pros: no need to have designing skills to create some nice images and your application is (probably) less in size.
Cons: a little more coding in order to scale it down and be more careful in the dps of each image.
EDIT to comment:
Yes. I would provide you a quick overview of what I am doing.
1) First of all create a drawable
folder, no need to create another one(there are always exceptions though).
2) All the images should be, as I mentioned, in the highest resolution according to the screen you want to support (probably 10 inch extra high density tablet).
3) This is the tricky part, I tend to create all the drawable in a X*X dimensions or in a 2X*X dimensions(4X*X, 8X*X ...) so as the ratio to be as exact(divided by 2) as it can be.
Then, in code. Let's say we have an image of 72x72 pixels and we want to make a small navigating icon for our application. This is approximately correct for a 10inch tablet but awfully big for a 3.2 inch mobile. So I create the ImageView in the layout like this:
<ImageView
android:id="@+id/previousPage"
android:layout_width="@dimen/small_icon"
android:layout_height="@dimen/small_icon"
android:src="@drawable/prev"
android:layout_marginRight="10dp" /> //...etc
As you can see I use specific width and height and not wrap content so an image like this with 72x72 pixels to a 30dp*30dp
ImageView has a flawless resolution. That's my way of doing the not so fancy, to a developer, "designer things".
And if you want different dimensions per version or something like that you can also create different values
folders.
Upvotes: 1
Reputation: 27596
This explains how to gracefully handle multiple DPIs: http://developer.android.com/training/basics/supporting-devices/screens.html
Essentially you'll have different directories for each DPI:
MyProject/
res/
drawable-xhdpi/
awesomeimage.png
drawable-hdpi/
awesomeimage.png
drawable-mdpi/
awesomeimage.png
drawable-ldpi/
awesomeimage.png
If it isn't supported by the API (xhpdi in your example) or if you don't have an image there, then it should default to the basic /drawable/
folder under /res/
Upvotes: 1
Reputation: 6201
You need different folder for different screen size phone , like mdp, ldp,hdp,
Check the android official documention
Thanks.
Upvotes: 0