public class MeasureUtil {
public static void measure(String tag, View view){
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
view.measure(w, h);
int width = view.getMeasuredWidth();
int height = view.getMeasuredHeight();
Log.d(tag, "width="+width+" / height="+height);
}
}
本文介绍如何利用MeasureUtil类来测量特定View组件的宽度和高度,通过传入自定义的测量规格来获取准确的尺寸信息。
896

被折叠的 条评论
为什么被折叠?



