convert Pixel To Sp - Android Graphics

Android examples for Graphics:Pixel

Description

convert Pixel To Sp

Demo Code


//package com.java2s;

import android.content.Context;

public class Main {
    public static int convertPxToSp(Context context, float pxValue) {
        return (int) (pxValue
                / context.getResources().getDisplayMetrics().scaledDensity + 0.5f);
    }//w  w  w  .  j av  a  2s. c  o m
}

Related Tutorials