第一步measure
measure
view.measure(MeasureSpec.UNSPECIFIED,MeasureSpec.UNSPECIFIED)
第二步现在你可以使用宽度getMeasuredWidth和高度使用getMeasuredHeight
getMeasuredWidth
getMeasuredHeight
int width = view.getMeasuredWidth(); int height = view.getMeasuredHeight();