I have some android code of a custom FrameLayout. The code changes some textView text.
I see the change take effect only when i call super.onMeasure(...,...)
I would expect it to call onMeasure() automatically when the text change via code or when I call view.invalidate()
why is the later not effecting the UI?
@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);
}
is calling super.onMeasure() at the end more efficient than calling view.requestLayout()?
Try to call requestLayout() for your view. invalidate() means that onDraw will be called for your view. But if your view changes its bounds you have to call requestLayout.