final float scale = getContext().getResources().getDisplayMetrics().density;
final float densityDpi = getContext().getResources().getDisplayMetrics().densityDpi;
float pxPerInch = 340; // default value - note it's a new density in API version 9.
switch(densityDpi){
case DisplayMetrics.DENSITY_LOW:
pxPerInch = 120 * scale;
break;
case DisplayMetrics.DENSITY_MEDIUM:
pxPerInch = 160 * scale;
break;
case DisplayMetrics.DENSITY_HIGH:
pxPerInch = 240 * scale;
break;
}
출처 : http://blog.naver.com/lowmans/100123712145
댓글 없음:
댓글 쓰기