RecyclerView显示流程
发布时间
阅读量:
阅读量
本次对RecyclerView绘制流程的分析是基于源码28版本展开的。由于RecyclerView继承自ViewGroup,作为一款自定义View,其必然要经历onMeasure()、onLayout()以及onDraw()这三个核心流程,因此可以从这些环节作为切入点进行深入探讨。在此假设RecyclerView.LayoutManager具体实现为LinearLayoutManager,如需进一步了解其实现细节,可前往对应的manager模块进行查阅。

onMeasure()方法解析
protected void onMeasure(int widthSpec, int heightSpec) {
// 1. 判断是否设置layoutManager
if (this.mLayout == null) {
// 如果不设置LayuytManager那么Rv宽高就只为padding,显示为空白
this.defaultOnMeasure(widthSpec, heightSpec);
} else
全部评论 (0)
还没有任何评论哟~
