Android examples for User Interface:Screen Size
get Screen Dimension Dp
//package com.java2s; import android.content.Context; import android.util.DisplayMetrics; import android.util.Pair; public class Main { public static Pair<Float, Float> getScreenDimensDp(Context context) { DisplayMetrics displayMetrics = context.getResources() .getDisplayMetrics();//ww w . j a v a 2s . c o m float dpWidth = displayMetrics.widthPixels / displayMetrics.density; float dpHeight = displayMetrics.heightPixels / displayMetrics.density; return new Pair(dpWidth, dpHeight); } }