出现这种情况很可能是因为设置了animation,并且调用了setFillAfter(true),这就会导致setVisibility无效,只需要调用一下clearAnimation()方法或者去掉setFillAfter(true)语句即可。

实验证明只要在setVisibility之前设置View的mCurrentAnimation为null就可以,因此调用setAnimation(null)也是可以的。从源码来看setFillAfter为false时也会间接导致调用clearAnimation,而clearAnimation在这里使setVisibility有效的原因也是置mCurrentAnimation为null了。

setFillAfter为false时间接导致clearAnimation:

而mCurrentAnimation使GONE无效的初步分析很可能是下面的代码造成:

在dispatchDraw子View的时候,尽管不为VISIBLE,由于是||的关系,也会导致drawChild被调用。而drawChild的代码如下:

    /**
* Draw one child of this View Group. This method is responsible for getting
* the canvas in the right state. This includes clipping, translating so
* that the child's scrolled origin is at 0, 0, and applying any animation
* transformations.
*
* @param canvas The canvas on which to draw the child
* @param child Who to draw
* @param drawingTime The time at which draw is occurring
* @return True if an invalidate() was issued
*/
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
return child.draw(canvas, this, drawingTime);
}

参考:http://bbs.csdn.net/topics/390311261

http://blog.csdn.net/xxxzhi/article/details/8846248

http://stackoverflow.com/questions/8690029/why-doesnt-setvisibility-work-after-a-view-is-animated

http://www.cnblogs.com/liulipeng/p/3962101.html

最新文章

  1. HTML5 video标签播放视频下载原理
  2. 通过rem编写自适应移动端要点
  3. 安装mysql 5.7+版本缺少data文件夹
  4. Python学习总结11:获取当前运行类名和函数名
  5. 【LeetCode OJ】Best Time to Buy and Sell Stock II
  6. 如何教你在NIPS会议上批量下载历年的pdf文档(另附04~14年NIPS论文下载链接)
  7. web之ios开关按钮
  8. JS图片自动或者手动滚动效果(支持left或者up)
  9. 全新的 flow.ci Dashboard UI 上线
  10. Vue.js——vue-resource
  11. Linux从入门到放弃(为做一个开发+运维的全能性人才而奋斗)
  12. 『2019/4/8 TGDay1模拟赛 反思与总结』
  13. T-SQL :SQL Server 定义数据完整性 6大约束(三)
  14. BZOJ5418[Noi2018]屠龙勇士——exgcd+扩展CRT+set
  15. mybatis--Mapper 常见报错总结(持续总结)
  16. CSS3渐变——线性渐变
  17. 分区实践 注意分区名 p2018-01 p2018-02 被解释为同一分区名
  18. 自动下载和安装 MNIST 到 TensorFlow 的 python 源码 (转)
  19. AOSP 设置编译输出目录
  20. JSP在页面加载时调用servlet的方法

热门文章

  1. UDP/TCP
  2. Linux学习三:Ubuntu下使用minicom和开发板通信
  3. IP地址
  4. Json 字符串 转换为 DataTable数据集合
  5. 仿Spring读取配置文件实现方案
  6. Iphone连接win10电脑正常, itunes无法识别解决
  7. js中js数组、对象与json之间的转换
  8. location.hash详解
  9. Geometry Stage in Rendering pipeline (读书笔记2 --- Real-Time rendering)
  10. delpin常用函数