@@ -0,0 +1,1790 @@
+/**   %0A * @Title: DisplayUtils.java %0A * @Package me.pc.mobile.helper.util %0A * @Description: TODO%0A * @author SilentKnight %7C%7C happychinapc%5Bat%5Dgmail%5Bdot%5Dcom   %0A * @date 2014 2014%E5%B9%B412%E6%9C%884%E6%97%A5 %E4%B8%8B%E5%8D%883:55:29 %0A * @version V1.0.0   %0A */%0Apackage me.pc.mobile.helper.v14.util;%0A%0Aimport android.content.Context;%0A%0A/**%0A * @ClassName: DisplayUtils%0A * @Description: TODO%0A * @author SilentKnight %7C%7C happychinapc@gmail.com%0A * @date 2014%E5%B9%B412%E6%9C%884%E6%97%A5 %E4%B8%8B%E5%8D%883:55:29%0A * %0A */%0Apublic final class DisplayUtils %7B%0A%09private DisplayUtils() %7B%0A%09%7D%0A%0A%09public static int px2Dp(Context ctx, float pxValue) %7B%0A%09%09final float density = ctx.getResources().getDisplayMetrics().density;%0A%09%09return (int) (pxValue / density + 0.5f);%0A%09%7D%0A%0A%09public static int dp2Px(Context ctx, float dpValue) %7B%0A%09%09final float density = ctx.getResources().getDisplayMetrics().density;%0A%09%09return (int) (dpValue * density + 0.5f);%0A%09%7D%0A%0A%09public static int sp2Px(Context ctx, float spValue) %7B%0A%09%09final float scaledDensity = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09return (int) (spValue * scaledDensity + 0.5f);%0A%09%7D%0A%0A%09public static int px2Sp(Context ctx, float pxValue) %7B%0A%09%09final float scaledDensity = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09return (int) (pxValue / scaledDensity + 0.5f);%0A%09%7D%0A%0A%09public static int dp2Sp(Context ctx, float dpValue) %7B%0A%09%09final float density = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09final float scaledDensity = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09return (int) (dpValue * density / scaledDensity + 0.5f);%0A%09%7D%0A%0A%09public static int sp2Dp(Context ctx, float spValue) %7B%0A%09%09final float density = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09final float scaledDensity = ctx.getResources().getDisplayMetrics().scaledDensity;%0A%09%09return (int) (spValue * scaledDensity / density + 0.5f);%0A%09%7D%0A%7D%0A

Create DisplayUtils.java