我看到改变只有在我打电话时才会生效
super.onMeasure(...,...)
onMeasure()
当文本通过代码更改或我呼叫时自动
view.invalidate()
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (myAccountView.getVisibility() == GONE) {
return;
}
//some more code
for (int i = 0; i < chipTexts.size(); i++) {
String text = chipTexts.get(i);
myAccountView.setText(text);
if (myAccountView.getPaint().measureText(text) <= textMaxWidth) {
break;
}
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
正在呼叫
super.onMeasure()
最后比打电话更有效率
view.requestLayout()