LayoutInflater hook点
在Activity里执行setContentView或者inflate布局文件最终都会走到如下代码:
LayoutInflater.java
View createViewFromTag(View parent, String name, Context context, AttributeSet attrs,
boolean ignoreThemeAttr) {
...
try {
View view;
if (mFactory2 != null) {
//1 hook点 mFactory2优先
view = mFactory2.onCreateView(parent, name, context, attrs);
} else if (mFactory != null) {
//2 hook点
view = mFactory.onCreateView(name, context, attrs);
} else {
view = null;
}
if (view == null && mPrivateFactory != null) {
view = mPrivateFactory.onCreateView(parent, name, context, attrs);
}
//如果fatory2、factory都返回null则进入函数体
if (view == null) {
final Object lastContext = mConstructorArgs[0];