Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;

import android.util.DisplayMetrics;
import android.util.TypedValue;

public class Main {

    public static int dipToPix(Context context, int dip) {
        int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip,
                context.getResources().getDisplayMetrics());
        return size;
    }

    public static DisplayMetrics getDisplayMetrics(Context context) {
        // DisplayMetrics dm = new DisplayMetrics();
        // activity.getResources().getDisplayMetrics();
        // activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
        return context.getResources().getDisplayMetrics();
    }
}