Android编程之分辨率处理相关代码段合集

2019-12-10 19:54:05于海丽

3. 根据手机的分辨率从 px(像素) 的单位 转成为 dp:

 

 
  1. public static int px2dip(Context context,float pxValue) {  final float scale = context.getResources().getDisplayMetrics().density; 
  2. return (int) (pxValue / scale + 0.5f) - 15;  } 

希望本文所述对大家Android程序设计有所帮助。


注:相关教程知识阅读请移步到Android开发频道。