Java tutorial
//package com.java2s; import android.view.View; public class Main { public static int getWidth(View view) { if (view == null) { throw new IllegalArgumentException("view is null"); } view.measure(0, 0); return view.getMeasuredWidth(); } public static int getMeasuredWidth(View view) { if (view == null) { throw new IllegalArgumentException("view is null"); } view.measure(0, 0); return view.getMeasuredWidth(); } }