Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image varies significantly in its density-independent (dip) size

I have finished the coding of my app, and am running Lint to make sure all performance issues are resolved.

I have created graphics for ldpi, mdpi, hdpi & xhdpi; but Lint is telling me something is wrong:

The image btn_homepage_journal.png varies significantly in its density-independent (dip) size across the various density versions: 
drawable-xhdpi\btn_homepage_journal.png: 93x75 dp (186x149 px), 
drawable-hdpi\btn_homepage_journal.png: 76x61 dp (114x92 px), 
drawable-mdpi\btn_homepage_journal.png: 61x49 dp (61x49 px), 
drawable-ldpi\btn_homepage_journal.png: 48x48 dp (36x36 px)

My mdpi test device is a Galaxy Ace, and my xhdpi test device is a Galaxy S3 and the graphics look fine.

I don't understand what this warning is trying to tell me: For my xhdpi image of 186x149 px (which fits perfectly in my xhdpi layout), what is the 93x75 dp referring to?

Here are the images I'm using in each dpi folder:

ldpimdpihdpixhdpi

like image 992
DaveSav Avatar asked Apr 07 '13 00:04

DaveSav


1 Answers

Lint is showing you what the density independent size would be for each of those images, or basically what the mdpi size would be if it had to change the size for you. The relative sizes it expects would be: xhdpi: 200% hdpi: 150% mdpi: 100% ldpi; 75% So if your mdpi image is 61x49, it would expect your ldpi to be 75% of that, or 46x37. also, it would expect your xhdpi to be 122x98 instead of the 186x149 that you have.

So looking at each number set-- the left side essentially indicates what size the image would appear to be, if it was resized for an mdpi display. So in theory this should be true:

xhdpi*0.5 == hdpi * 0.667 == mdpi == ldpi*1.33

In practice, you can make it any way you want, but it will be tough for your layouts to correspond with each other.

like image 132
HalR Avatar answered Sep 20 '22 21:09

HalR