// int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); // int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); // inflate.measure(w, h); // int width = inflate.getMeasuredWidth(); // int height = inflate.getMeasuredHeight();
原文:https://www.cnblogs.com/zhangxuetao/p/13437648.html