@@ -0,0 +1,686 @@
+/*%0A * DimensionUtils.java%0A *%0A * Author: Ming Tsang%0A * Copyright (c) 2015 Ming Tsang%0A * Refer to LICENSE for details%0A */%0A%0Apackage com.nkming.utils.unit;%0A%0Aimport android.content.Context;%0Aimport android.util.DisplayMetrics;%0Aimport android.util.TypedValue;%0A%0Apublic class DimensionUtils%0A%7B%0A%09public static float dpToPx(Context context, float dp)%0A%09%7B%0A%09%09DisplayMetrics dm = context.getResources().getDisplayMetrics();%0A%09%09return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, dm);%0A%09%7D%0A%0A%09public static float spToPx(Context context, float sp)%0A%09%7B%0A%09%09DisplayMetrics dm = context.getResources().getDisplayMetrics();%0A%09%09return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, dm);%0A%09%7D%0A%7D%0A

Convert dp/sp to pixel value