Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mdpi image is too small for 10" android tablet

I have drawables for each density as ldpi,mdpi,hdpi and xhdpi.

Problem: Both 10" tablet device (1280x800) and a handset device 320x480 uses medium density. I have an 35x35 mdpi image. But this image is too small for tablet whereas it is ok for handset.

I read relevant documents. But I guess I couldn't understand sth significant. Is there anyway for tablet use xhdpi images or I wonder how to use bigger images for mdpi tablet.

like image 809
efeyc Avatar asked Mar 29 '12 13:03

efeyc


2 Answers

You should add a second identifier large and/or xlarge to your drawable folders. Increase the size in drawable-xlarge-mdpi until you are happy with the result while the drawable-mdpi will be the same size as before.

This increases the app size, but it will fix your issue.

like image 183
WarrenFaith Avatar answered Oct 20 '22 00:10

WarrenFaith


If you want to achieve this without increasing your app size, there is a way to let a high density screen and a large medium density screen use the same resource. You need to place the image you want to re-use in the 'drawable-nodpi' folder. This will stop the platform performing its own scaling when using it. For example, assuming you have a resource called 'my_resource', if you want the tablet-size screen to use your xhdpi resource, then move it out of drawable-xhdpi and rename it like this:

/drawable-nodpi/my_resource_xhdpi.png

Then in both the drawable-xhdpi and drawable-xlarge folders, create a file called my_resource.xml which looks like this:

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

Now when you use @drawable/my_resource, the xhdpi version will be used by xhdpi screens and xlarge screens, and you only have to maintain one version of the image. I use this technique quite a lot and it works really well. Hope that helps!

like image 35
kingraam Avatar answered Oct 20 '22 01:10

kingraam