convert Dip To Pixel - Android Graphics

Android examples for Graphics:Pixel

Description

convert Dip To Pixel

Demo Code


//package com.java2s;

import android.content.Context;

public class Main {
    public static int convertDipToPx(Context context, int dip) {
        float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dip * scale + 0.5f * (dip >= 0 ? 1 : -1));
    }//ww w . j  av a2s  . com
}

Related Tutorials