Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only use XHDPI drawables in Android app?

If you're planning to support LDPI, MDPI, HPDI, and perhaps XHDPI in the near future, is it ok to only include XHDPI drawables in the project and let the devices scale them to their desired resolution?

I've tested to resize the drawables into MDPI and HDPI in Photoshop and then compared the result with XHDPI drawables only resized by Android, and I can't see any difference at all. Is it bad design to take this shortcut? It would be nice to not have to resize each and every drawable into 3 different resolutions.

Planning to use target SDK is 2.1 or 2.2.

BR Emil

like image 687
Emil Avatar asked May 13 '11 23:05

Emil


People also ask

Is there a way to create Xxhdpi Xhdpi Hdpi Mdpi and LDPI Drawables from a large scale image?

Option #1: Just ship the -xxhdpi drawables and let Android downsample them for you at runtime (downside: will only work on fairly recent devices, where -xxhdpi is known). Option #2: Use Android Asset Studio to downsample them for you. Option #3: Automate the process within a graphics editor, per ssantos' answer.

How do you add Drawables?

Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import. Figure 3: Select Import Drawables from the dropdown menu.

How do I make a drawable Xxhdpi folder?

Simply go to project Explorer and change your View from Android to project from drop Down and you are good to go. There you can simply create folder like we do in Eclipse. And in android project view it is hidden but when you switch to project. You can create folder like drawable-hdpi,drawable-xhdpi .

What is Xxhdpi density?

xxhdpi device of 1080 x 1920 pixels (Samsung S4, S5) will be of 360 X 640 dp.


2 Answers

I guess that's a good way to go. The only downside I can think of is the resource overhead on small scale devices and possible artifacts because of the downscaling. Actually at this year's Google IO Chris Pruett recommended embedding only high resolution assets and let opengl handle the scaling.

like image 109
Will Kru Avatar answered Oct 07 '22 04:10

Will Kru


As of Android 1.6, different densities are handled, including XHDPI (which wasn't officially added until 2.2). Your app will first look for an image matching its density, but it can look into larger "buckets" like XHDPI and then perform the scaling for you.

It's best to include specific assets for the densities you want to support. An image that's 100x100 takes 40kb; and image that's 200x200 takes 160k (uncompressed). So, any XHDPI assets used on MDPI devices have four times the amount of data that you need, which has to be handled when the app starts and your resources are prepared. Lower memory use means greater efficiency, less chance for an OutOfMemoryException.

Further, specific types of images will look bad when automatically scaled. In particular, images with fine lines or fine patterns will have their detail muddied. When you shrink the images by hand, you can choose the algorithm that best matches your needs (linear, bicubic, lanczos, etc.).

If you're worried about the time it takes to do the resizing yourself, you can incorporate a batch process or use tools such as Nine Patch Resizer: http://code.google.com/p/9patch-resizer/

like image 26
Ian G. Clifton Avatar answered Oct 07 '22 05:10

Ian G. Clifton