when does the View.ondraw method get called
a View's onDraw() is called when:
- The view is initially drawn
- Whenever invalidate() is called on the view
Invalidate can be called by you or the system whenever needed. For example, a lot of Views change how they look onTouch, like an EditText getting an outline and cursor, or a button being in the pressed state. Due to this, Views are redrawn on touch.
I agree that it would be nice to have a document that detailed the working of Views, and if one exists and somebody knows where to find it, please let us know.
If you set a background drawable for a View, then the View will draw it for you before calling back to its onDraw() method.
onAttachedToWindow () is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).
invalidate() mark the area defined by dirty as needing to be drawn. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
see also:
http://stackoverflow.com/questions/11912406/view-ondraw-when-does-it-get-called
when does the View.ondraw method get called的更多相关文章
- ui5 call view or method from another view
// call view or method from another view //# view call // var view2=sap.ui.jsview("ui5d.popup01 ...
- view ondraw
窗口发生重绘时会被应用程序的窗口框架给调用 要使输出的东西始终能在窗口中看到 就可以使用该函数 窗口从到有的时候就会产生WM_PAINT消息,让窗口发生重绘 这是程序就会执行到ONDRAW函数处 所 ...
- torch.Tensor.view (Python method, in torch.Tensor)
返回具有相同数据但大小不同的新张量.返回的张量共享相同的数据,必须具有相同数量的元素,但可能有不同的大小. Example >>> x = torch.randn(4, 4) > ...
- Android 官方文档:(一)动画和图像 —— 1.5 画布和画图
The Android framework APIs provides a set 2D drawing APIs that allow you to render your owncustom gr ...
- The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new View.OnClickListener(){}, String, int)
package comxunfang.button; import android.support.v7.app.ActionBarActivity; import android.os.Bundle ...
- 虾扯蛋:Android View动画 Animation不完全解析
本文结合一些周知的概念和源码片段,对View动画的工作原理进行挖掘和分析.以下不是对源码一丝不苟的分析过程,只是以搞清楚Animation的执行过程.如何被周期性调用为目标粗略分析下相关方法的执行细节 ...
- Android 自定义View及其在布局文件中的使用示例
前言: 尽管Android已经为我们提供了一套丰富的控件,如:Button,ImageView,TextView,EditText等众多控件,但是,有时候在项目开发过程中,还是需要开发者自定义一些需要 ...
- View绘制机制
View 绘制机制 1. View 树的绘图流程 当 Activity 接收到焦点的时候,它会被请求绘制布局,该请求由 Android framework 处理.绘制是从根节点开始,对布局树进行 me ...
- 自定义控件(View的绘制流程源码解析)
参考声明:这里的一些流程图援引自http://a.codekk.com/detail/Android/lightSky/%E5%85%AC%E5%85%B1%E6%8A%80%E6%9C%AF%E7% ...
随机推荐
- EasyDropDown – 很棒的下拉菜单 含精美主题
EasyDropDown 是一个 jQuery 插件,你可以毫不费力地将简陋的 Select 元素设置为可定制风格的下拉菜单,用于表单或者一般的导航.和著名的下拉插件 Chosen 很像,但是具有自己 ...
- mysql查询优化(持续更新中)
1. 索引不会包含有NULL值的列 (1) 应尽量避免在where子句中对字段进行null值判断,否则将导致引擎放弃使用索引而进行全表扫描 (2) 数据库设计时不要让字段的默认值 ...
- [BI基础] 一些不得不了解的概念
0.Hadoop hadoop主要是用来对海量数据进行存储和计算的. 它本身是一个分布式系统,核心由分布式文件系统hdfs,和分布式计算框架mapreduce组成,在存储和计算时能够发挥出集群中每台机 ...
- Hibernate缓存机制
缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据,在特定的时刻或事 ...
- 生产订单修改删除组件BDC
可用函数修改:CO_XT_COMPONENT_CHANGE,一次一个 FORM prm_change_bom . DATA:gw_zstypf TYPE zstypf. DATA:lv_rspos T ...
- postgres 正则表达式
PostgreSQL正则表达式 基础: Operator Description Example ~ Matches regular expression, case sensitive 'thoma ...
- ie6 ie7 绝对定位 相对定位 层被遮住
relative 上加上z-index有多个,则z-index递减, absolute层显示则不会被其它标签挡住.
- BZOJ1570 [JSOI2008]Blue Mary的旅行
建分层图,每一层表示一天的情况 从S向第0层的1号点连边,每层的n向T连INF的边 枚举天数,每多一天就多建一层然后跑最大流,如果当前流量大于人数则输出答案 由于路径长度不会超过n,因此tot个人走这 ...
- mysql 在insert 时防止出现主键冲突错误的方法
在mysql中插入数据的时候常常因为主键存在而冲突报错,下面有两个解决方法: 1.在insert 语句中添加ignore 关键字,如:insert ignore into table (id,name ...
- 标签视图控制器UITabBarController
标签视图控制器 UITabBarController FirstViewController*first = [[FirstViewController alloc] init]; //创建一个UIT ...