We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
主要绘制流程如下:
measure、layout、draw的遍历如下:
View的measure()默认实现做了一些缓存检查之类的工作,最终还是调用了onMeasure(),下面展示onMeasure()做了什么:
View大小的控制是由父View、layout.xml文件、以及View本身共同完成的,父View会提供给子View参考的大小,而开发人员可以在layout.xml文件中指定View的大小,然后View本身会对最终的大小进行拍板
measure 过程的结果:所有的View、ViewGroup都调用setMeasured()设置了自己的宽高,以备 layout 过程使用。
无论是View还是ViewGroup,layout()都可以使用View的默认方式:
layout 过程的结果:设置好View、ViewGroup的左上右下坐标
onDraw()原理简单,自定义View需要重点实现,以绘制出想要的内容。
draw()虽都不重写,但很重要,View的默认实现已经把所有步骤都做好了:
ViewGroup已经重写了dispatchDraw方法,实现了遍历子View绘制,所以一般自定义ViewGroup时不需要重写
以上四个步骤按序调用,完成了所有绘制。
draw 过程的结果:将图像绘制到 Canvas 上。
http://blog.csdn.net/yanbober/article/details/46128379 http://blog.csdn.net/guolin_blog/article/details/16330267 http://developer.android.com/intl/zh-cn/guide/topics/ui/how-android-draws.html http://blog.csdn.net/luoshengyang/article/details/8372924 http://www.codekk.com/blogs/detail/54cfab086c4761e5001b253f
The text was updated successfully, but these errors were encountered:
No branches or pull requests
主要绘制流程如下:
measure、layout、draw的遍历如下:
measure 过程
View的measure()默认实现做了一些缓存检查之类的工作,最终还是调用了onMeasure(),下面展示onMeasure()做了什么:
View大小的控制是由父View、layout.xml文件、以及View本身共同完成的,父View会提供给子View参考的大小,而开发人员可以在layout.xml文件中指定View的大小,然后View本身会对最终的大小进行拍板
measure 过程的结果:所有的View、ViewGroup都调用setMeasured()设置了自己的宽高,以备 layout 过程使用。
layout 过程
无论是View还是ViewGroup,layout()都可以使用View的默认方式:
layout 过程的结果:设置好View、ViewGroup的左上右下坐标
draw 过程
onDraw()原理简单,自定义View需要重点实现,以绘制出想要的内容。
draw()虽都不重写,但很重要,View的默认实现已经把所有步骤都做好了:
ViewGroup已经重写了dispatchDraw方法,实现了遍历子View绘制,所以一般自定义ViewGroup时不需要重写
以上四个步骤按序调用,完成了所有绘制。
draw 过程的结果:将图像绘制到 Canvas 上。
参考
http://blog.csdn.net/yanbober/article/details/46128379
http://blog.csdn.net/guolin_blog/article/details/16330267
http://developer.android.com/intl/zh-cn/guide/topics/ui/how-android-draws.html
http://blog.csdn.net/luoshengyang/article/details/8372924
http://www.codekk.com/blogs/detail/54cfab086c4761e5001b253f
The text was updated successfully, but these errors were encountered: