简体   繁体   中英

Should I keep images in both drawable and drawable-hdpi folder?

I have searched for a time about drawable folder. But I want to make sure what I get is correct, so I create this question just to confirm it.

The issue is:

I have a.png ( hd image) in drawable-hdpi folder (and only in this folder). I run my app on mdpi devices. What will happen? From what i read on the internet. I think: 1. Android will take a look at drawable folder. 2. Because there is no a.png in this folder, Android will look at others folder and finally It will get a.png file in hdpi folder. 3. Android will scale a.png image down 1.5 times to fit mdpi devices. 4. The a.png image after scaling will be displayed on screen.

Please correct me if I'm wrong. Thank you.

you could use xml-resources. put the file a.xml in your hdpi folder and reference from there your a.png wich you put in your drawable-folder.

bitmap example, there are other ways (ninepatch, rotate, scale, selector,...):

<?xml version="1.0" encoding="utf-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/a"/>

that way, at least, you don`t have to dublicate images.

I am too late but i think i have an answer. @Paul yes, you are right. you can place an high quality image in your xxhdpi folder and android will automatically scale down it for you(depend on screen size image may not be fit as best). Pretty simple. Then why need to paste other folders? Interestingly i found that if you use animations in presenting images it will not have smooth transition.That's a one reason to place images in all the folders.

Yes .You are right. but sometimes it does not happen. Once i kept an image in drawable mdpi and later i find that wen i used that app on an 10 inch tab the image got blurred.. So its better to keep the image in all folder starting from hdpi. I know it does not make any sense but i tried my app on my another tab 7' here the image was not blur rather it got short. I tried keeping the image in all folder and then ran on my both the devices it was better. I faced a problem with HD image as it was not shown on the screen.. I got the background plain white.

better keep the image in all folder. try to keep in hdpi so that its resolution doesn't get affected on devices.

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