I'm trying to figure out the optimization for my custom view. I'm wondering if the calling to View.setVisibility(View.VISIBLE) forces the Android framework to update the view visibility (<- forcing the view to redraw) even if the view is already visible.
No, it doesn't.
Take a look at setVisibility():
public void setVisibility(int visibility) {
setFlags(visibility, VISIBILITY_MASK);
if (mBGDrawable != null) mBGDrawable.setVisible(visibility == VISIBLE, false);
}
It simply calls setFlags(), which immediately returns if nothing has changed:
....
int changed = mViewFlags ^ old;
if (changed == 0) {
return;
}
Even if it(somehow) got past there, it then checks for the individual flags changing, and only updates if one of them is different than it was.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With