Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Licensed Materials - Property of IBM
 *  Copyright IBM Corporation 2014, 2015. All Rights Reserved.
 */

import android.content.Context;

import android.util.TypedValue;

public class Main {
    /**
     * Converts pixels to density-independent pixels (dip).
     *
     * @param context
     * @param pixels
     * @return the converted number of pixels based on the display metrics
     */
    public static int pixelsToDip(Context context, int pixels) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, pixels,
                context.getResources().getDisplayMetrics());
    }
}