情况一: root =null, attachToRoot = false;
View temp = createViewFromTag(root, name, attrs);
// Inflate all children under temp
rInflate(parser, temp, attrs, true);
return temp;
情况二:root != null, attachToRoot = false;
View temp = createViewFromTag(root, name, attrs);
ViewGroup.LayoutParams params = root.generateLayoutParams(attrs);
temp.setLayoutParams(params);
// Inflate all children under temp
rInflate(parser, temp, attrs, true);
return temp;
情况三:root != null, attachToRoot = true;
View temp = createViewFromTag(root, name, attrs);
ViewGroup.LayoutParams params = root.generateLayoutParams(attrs);
temp.setLayoutParams(params);
// Inflate all children under temp
rInflate(parser, temp, attrs, true);
root.addView(temp, params);
return root;
总结:
root为空时, 返回temp。
root 不为空时, attachToRoot = true 。 返回root;
attachToRoot = false。设置temp layoutParams 。返回temp。
本文详细解析了视图处理流程的三种情况,包括root为空、root不为空且不附加到root、root不为空且附加到root的具体实现逻辑。
873

被折叠的 条评论
为什么被折叠?



