zoukankan      html  css  js  c++  java
  • android draw() onDraw() dispathDraw() onDrawScrollBars

    /*
    * Draw traversal performs several drawing steps which must be executed
    * in the appropriate order:
    *
    * 1. Draw the background
    * 2. If necessary, save the canvas' layers to prepare for fading
    * 3. Draw view's content
    * 4. Draw children
    * 5. If necessary, draw the fading edges and restore layers
    * 6. Draw decorations (scrollbars for instance)
    */

    // Step 1, draw the background, if needed

    // skip step 2 & 5 if possible (common case)

    // Step 3, draw the content
    if (!dirtyOpaque) onDraw(canvas);

    // Step 4, draw the children
    dispatchDraw(canvas);

    // Step 6, draw decorations (scrollbars)
    onDrawScrollBars(canvas);

    onDraw():When custom a view, overriding this method

    measure(内部调用onMeasure)

    layout(内部调用onLayout)

    draw(内部调用ondraw、dispatchDraw、onDrawScrollBars)

    CustomView Override onDraw()

    CustomViewGroup Override dispatchDraw()

    ondraw:draw View's content

    dispatchDraw:draw children

    处理组件的布局通常要重写onMesure和onLayout这两个方法

    Reference:

    http://blog.csdn.net/czh0766/article/details/5790295

    http://blog.csdn.net/scorplopan/article/details/6302827

  • 相关阅读:
    14 DOM案例
    13 client&offset&scroll
    12 DOM操作节点&定时器
    脚下的路
    甘于寂寞
    为创意埋单,为知识产权埋单,为精细化服务埋单
    在那东山顶上
    你们都以落第为耻,我却以落第动心为耻
    决定经常性更新博客
    怎样以最快的速度导入mysql
  • 原文地址:https://www.cnblogs.com/ZacharyHodgeZou/p/3725672.html
Copyright © 2011-2022 走看看