Ryan
Ryan

Reputation: 10131

What is the size I should create for Android app?

My device's logical resolution is 480x800 and density is mdpi, I want to have a background image occupy half of the screen, which is logically 240x400, so what image I should create in photoshop and put under the drawable-mdpi folder?

My understanding is if my image was created in desktop with 72 dpi, then I should prepare my image as ..

w = (240 * 160 / 72) = 533
h = (400 * 160 / 72) = 888

So I should prepare an image in photoshop using the size of 533x888 (72dpi) and put under the drawable-mdpi folder?

Upvotes: 1

Views: 92

Answers (1)

Nicholas
Nicholas

Reputation: 2205

You could take the approach you outline but you could also put a high-resolution image in the res/drawable folder and set the width and height in the layout files with device independent pixels (dip or dp):

<ImageView
    android:id="@+id/my_id"
    android:layout_width="240dp"
    android:layout_height="400dp"
    android:contentDescription="@string/my_image_description"
    android:src="@drawable/my_image"/>

Of course the scaling of the images can hurt the overall quality but you might also encounter other mdpi devices that have a different resolution and thus the image will be scaled anyhow.

Upvotes: 1

Related Questions