Drawing Phase: Mechanics of onDraw

The draw traversal is implemented in the View's draw() method. The protocol implemented by this method is:

Draw the backgroundDraw view's content by delegating to onDraw()Draw children by delegating to dispatchDraw()Draw decorations such as scroll bars

As the trigger for the layoutphase is requestLayout(), thetrigger for the draw phase is invalidate(). When you invalidate a view, it goes up the chain and results in scheduling of the traversal from the view root.

Implementing Measure Pass

In the measure pass, a custom view needs to return the size that it wants when it get painted in the subsequent draw pass. The view needs to set its dimentsions in the overriden onMeasure(). Setting the size of a view is not straightforward. Your view sizedepends onhow yourview is going to fit with the rest ofthe views. Android passes something called a mode bit to onMeasure()to give context to calculating the size of the view.

This mode bit can be one of three:AT_MOST, UNSPECIFIED, and EXACT.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android点击EditText外区域收起键盘
  2. Error:more than one library with packa
  3. Android——SeekBar(进度、音量大小的控件
  4. Android中保存图片到本地并更新到相册及
  5. Android(安卓)SystemUI 闪烁
  6. Android中应用的快捷方式的创建
  7. android使用HttpURLConnection上传文件同
  8. Android中四大组件概述以及各自作用
  9. android之ScrollView里嵌套ListView
  10. Android(安卓)Things正式版发布啦