》屏幕尺寸及控件尺寸 /** * Created by Kvin on 2016/1/5. */ public class MetricsUtils { //get Screen Metrics public static DisplayMetrics winMetrics(Context context) { DisplayMetrics metrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics); return metrics; } //get Controls Metrics public static View conMetrics(View v) { int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); v.measure(w, h); return v; } }