Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.res.TypedArray; public class Main { public static int getDimensionPixelSize(Activity activity, int attr, int defaultValue) { int[] attrs = new int[] { attr }; TypedArray ta = activity.obtainStyledAttributes(attrs); int value = ta.getDimensionPixelSize(0, defaultValue); ta.recycle(); return value; } }