简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM