setVisibility(View.VISIBLE);setVisibility(View.GONE);setVisibility(View.INVISIBLE);都不起作用了,后来发现是设置动画原因。设置之前调用一下clearAnimation()就好了。
跟了一下源码发现setVisibility()方法会调用这个函数:
/**
* Do not invalidate views which are not visible and which are not running an animation. They
* will not get drawn and they should not set dirty flags as if they will be drawn
*/
private boolean skipInvalidate() {
return (mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null &&
(!(mParent instanceof ViewGroup) ||
!((ViewGroup) mParent).isViewTransitioning(this));
}
这个问题纠结的半天,网上搜了好久,没找到靠谱的答案。碰到bug查查源码是个好习惯。