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底层开发之Audio HAL
  2. Android中使用ViewPager制作广告栏滚屏效
  3. Android(安卓)与 后台网络交互踩坑
  4. Android(安卓)下使用 JSON 实现 HTTP 请
  5. Android(安卓)dumpsys 使用之分析网络使
  6. Android(安卓)SDK的安装和Android命令行
  7. Android——使用AIDL实现进程间通讯简单
  8. android 开机动画和开机视频流程分析基于
  9. android根据uri或文件绝对路径获取文件基
  10. 详解android:scaleType属性