convert dp to pixel - Android Graphics

Android examples for Graphics:Pixel

Description

convert dp to pixel

Demo Code


//package com.java2s;

import android.content.res.Resources;

public class Main {

    public static final float DENSITY = Resources.getSystem()
            .getDisplayMetrics().density;

    public static int dp2px(int dp) {
        return Math.round(dp * DENSITY);
    }//from  ww  w.jav  a  2 s . co m
}

Related Tutorials