Android examples for android.graphics:Pixel
get Pixels from dps
import android.content.Context; public class Main { public static int getPixels(float dps, Context context) { float scale = context.getResources().getDisplayMetrics().density; int pixels = (int) (dps * scale + 0.5f); return pixels; }//from w w w . ja v a 2 s.c om }