Android自定义View的一些不知道的细节
原因:
详解:
/* * 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) */
先绘制背景,如果有必要,保存画布层,绘制内容,绘制孩子,绘制渐变,绘制装饰物。
if (!verticalEdges && !horizontalEdges) { // Step 3, draw the content if (!dirtyOpaque) onDraw(canvas); // Step 4, draw the children dispatchDraw(canvas); // Step 6, draw decorations (scrollbars) onDrawScrollBars(canvas); // we're done... return; }从这里我们可以看出draw方法的调用过程是这样子。
onDraw -> <span style="font-family: Arial, Helvetica, sans-serif;">dispatchDraw -> </span><span style="font-family: Arial, Helvetica, sans-serif;">onDrawScrollBars</span>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。