cm To Dpi - Android Graphics

Android examples for Graphics:Pixel

Description

cm To Dpi

Demo Code


//package com.java2s;
import android.util.DisplayMetrics;

public class Main {
    public static int cmToDpi(float size, DisplayMetrics metrics) {
        float totalDIP = metrics.densityDpi;
        float inches = size / 25.4f;
        return Math.round(inches * totalDIP);
    }/*from   w ww .  j  a v a2 s. c  o  m*/
}

Related Tutorials