使用setMeasure方法是无效的

setMeasuredDimension(width, height);

如果想设置,可以用LayoutParams

ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) getLayoutParams();
layoutParams.width = (int) mPaint.measureText("Do you like waht you see?");
setLayoutParams(layoutParams);

现在想是蠢了点,setMeasure是用来测量控件大小的,肯定是没用的

标签: 安卓, 自定义View

添加新评论