开发者

Android drawable paradigm!

开发者 https://www.devze.com 2023-03-13 19:53 出处:网络
I have been developing Android application since 3 to 4 months. I am naive, But pretty much exposed to all of the fundamentals regarding application development on android. However I found really pain

I have been developing Android application since 3 to 4 months. I am naive, But pretty much exposed to all of the fundamentals regarding application development on android. However I found really painful while developing application with lots of images, By saying images I mean one of my application has around 10 to 13 images(Small enough to accommodate screen size). The problem is I have to make different copies of it by making,

  • HDPI - High resolution support
  • MDPI - Medium resolution support
  • LDPI - Low resolution support

I have come up with an idea,

IDEA : My idea is to actually have only MDPI images in drawable folder, When my  
application will installed first time, I want my application to detect what type of 
resolution is supported by device? After knowing which resolution is supported one of my 
built in method will either use a MDPI version(images), if handset supports it or else 
it will scale up or scale down my images and stores into internal storage for future    
reference. When user uninstall my application I will remove these images from internal 
storage.

Now this idea has raised a question,

Question :

  1. 开发者_运维问答Whether this idea is feasible? and Programatically possible?
  2. If it is, Should I be really concerned about one time computational overhead?
  3. Is there any mechanism(third party) which can ease my problem? (I hate photoshop and scaling up and down all those images)

Any expert help or guidance will be a big favour!

Thanks in advance!

Krio


I dont really understand why you would do this. The system already basically does this for you. You dont have to specify different images for different display densities, the system just gives you the opportunity to so you can make your app look its best. If you only supply a single image the system will scale it appropriately for you based on the density of the handset.

As for help with scaling the images yourself for packaging, you could look at image magick. This is a powerful scriptable image manipulation tool. You might need to spend a bit of time getting up to speed with it, but I am sure you could write a script that you could reuse for all of your images after that to convert high dpi images to lower dpi ones by scaling down.


Take a look to this article. It describes how android handle directory names for resources. Also take a look a look to this - how android choose the best match for directory name. If you want to use the same resource for all dpis just place it in the default drawable folder.

0

精彩评论

暂无评论...
验证码 换一张
取 消