Java tutorial
//package com.java2s; import android.content.Context; import android.content.res.TypedArray; public class Main { public static int getPixelDimension(Context context, int attr) { TypedArray ta = context.obtainStyledAttributes(new int[] { attr }); int dimension = ta.getDimensionPixelSize(0, 0); ta.recycle(); return dimension; } }