Android examples for Graphics:Pixel
Conversion from DIPs (Density-independent pixels) to pixels
//package com.java2s; import android.content.Context; import android.content.res.Resources; public class Main { /**/*from w ww.java2 s . c o m*/ * Conversion from DIPs (Density-independent pixels) to pixels * @param context * @param dip * @return */ public static int convertDipsToPixels(Context context, int dip) { Resources resources = context.getResources(); float pixelValue = (dip * resources.getDisplayMetrics().density); resources = null; return (int) pixelValue; } }