Android setVisibility(View.GONE)无效的问题及原因分析
出现这种情况很可能是因为设置了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);
}
Android setVisibility(View.GONE)无效的问题及原因分析的更多相关文章
- Android的setVisibility(View.GONE)无效的问题及原因分析(转)
出现这种情况很可能是因为设置了animation,并且调用了setFillAfter(true),这就会导致setVisibility无效,只需要调用一下clearAnimation()方法或者去掉s ...
- Android的setVisibility(View.GONE)无效的问题及原因分析
出现这种情况很可能是因为设置了animation,并且调用了setFillAfter(true),这就会导致setVisibility无效,只需要调用一下clearAnimation()方法或者去掉s ...
- Android中View绘制流程以及invalidate()等相关方法分析
[原文]http://blog.csdn.net/qinjuning 整个View树的绘图流程是在ViewRoot.java类的performTraversals()函数展开的,该函数做的执行过程可简 ...
- Android中View绘制流程以及invalidate()等相关方法分析(转载的文章,出处在正文已表明)
转载请注明出处:http://blog.csdn.net/qinjuning 前言: 本文是我读<Android内核剖析>第13章----View工作原理总结而成的,在此膜拜下作者 .同时 ...
- Android中View绘制流程以及invalidate()等相关方法分析(转)
转自:http://blog.csdn.net/qinjuning 前言: 本文是我读<Android内核剖析>第13章----View工作原理总结而成的,在此膜拜下作者 .同时真挚地向渴 ...
- Android ListView异步载入图片乱序问题,原因分析及解决方式
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/45586553 在Android全部系统自带的控件其中,ListView这个控件算是 ...
- 子线程调用invalidate()产生“Only the original thread that created a view hierarchy can touch its views.”原因分析
目录 1.异常出处 2.从View.invalidate()方法开始分析 3.ViewRootImpl如何与View进行关联:从Activity的setContentView开始分析 3.1 最顶层的 ...
- Android之View绘制流程开胃菜---setContentView(...)详细分析
版权声明:本文出自汪磊的博客,转载请务必注明出处. 1 为什么要分析setContentView方法 作为安卓开发者相信大部分都有意或者无意看过如下图示:PhoneWindow,DecorView这些 ...
- Android升级ADT22后会报ClassNotFoundException的原因分析
http://blog.csdn.net/huzgd/article/details/8962702 1.ADT16下,只要add to path就是add to path并export:2.ADT2 ...
随机推荐
- android jni下c文件怎么输出logcat
#include <android/log.h> #define LOG_TAG "clog"#define LOGD(...) __android_log_print ...
- bzoj2687
整体二分+决策单调性 这个方法已经忘了... 决策单调性是指dp[i]由dp[1]->dp[i-1]更新,那么当dp[j]比dp[k]优且j>k时,对于i->n j都比k优 通过这个 ...
- Sense2vec with spaCy and Gensim
如果你在2015年做过文本分析项目,那么你大概率用的是word2vec模型.Sense2vec是基于word2vec的一个新模型,你可以利用它来获取更详细的.与上下文相关的词向量.本文主要介绍该模型的 ...
- 四、Chrome开发者工具详解(4)-Profiles面板
摘自: http://www.cnblogs.com/charliechu/p/6003713.html
- 【原】putty配置下载
文章出自:http://www.cnblogs.com/david-zhang-index/p/3205354.html putty配置下载,已经配置好了,颜色非常不错 PUTTY.zip
- 开源跨平台声波传输库:Sonic
简介 [Sonic](https://github.com/linyehui/sonic) 是一个跨平台的声波传输库(iOS & Android),技术上类似于[chirp](http://c ...
- 安装openstack出现的问题及解决
感谢http://www.cnblogs.com/nmap/p/6417163.html,参考这篇文章,我在虚拟机上部署成功了,后来因为虚拟机实在带不动,所以改装到物理机上,在实验室找到两台物理机,分 ...
- ASP.NET Core会议管理平台实战_汇总贴
ASP.NET Core会议管理平台实战 课程地址:https://ke.qq.com/course/389673?from=800004097#term_id=100464670 ASP.NET C ...
- 2-1Java简介
java程序执行流程 java平台:
- 简易DIV垂直居中阴影层笼罩JS实现
$(document).ready(init); function init() { var h = $(window).height(); var w = $(window).width(); /* ...