Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import android.content.Context; public class Main { public static int convertToDIP(Context context, int pixels) { return Math.round(pixels * context.getResources().getDisplayMetrics().density); // DIP } }