Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.util.DisplayMetrics;
import android.view.ViewGroup;

public class Main {
    public static int getHeightForDp(ViewGroup parent, float dp) {
        DisplayMetrics metrics = parent.getResources().getDisplayMetrics();
        float fpixels = metrics.density * dp;
        return (int) (fpixels + 0.5f);
    }
}