简体   繁体   中英

Android : How to create images for different sizes and densities?

I have an image view which has different size on normal and large sized screens(I achived it via dimens.xml), lets assume 100*100 dp on small and 133*133 dp on large sized screen.

I'm setting image to it programatically, let's say it is def.png

Now for best performance I should create 6 versions of def.png(assuming i cater only to mdpi, hdpi and xhdpi densities)

  1. small-mdpi - 100*100 px
  2. small-hdpi - 150*150 px
  3. small-xhdpi - 200*200 px

  4. large-mdpi - 133*133 px

  5. large-hdpi - 199*199 px
  6. large-xhdpi - 266*266 px

It means 6 def.png images, but I can put 3 of them because only 3 folders are available ie drawable-mdpi, drawable-hdpi, drawable-xhdpi .

How should I achieve best performance so that there will be less scaling up and down of Images ??

or

If it is not possible this way, then what are the alternatives ?

How to Support Multiple Screens:-

  • Explicitly declare in the manifest which screen sizes your application supports
  • Provide different layouts for different screen sizes
  • Provide different bitmap drawables for different screen densities

Source :- https://developer.android.com/guide/practices/screens_support.html#support

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