inflate「inflate to 300kpa」
inflate详解
生成布局的时候,经常会用到LayoutInflater.from(context).inflate(layoutRes, parent, false)方法,一直不知其具体实现以及各参数作用,靠猜来实现? 很惭愧,趁闲暇赶紧补补~
常用到的inflate方式:

LayoutInflater.inflate有多个重载的方法,但是最后都调用的是同一个
public View inflate(XmlPullParser parser, @Nullable ViewGroup root, boolean attachToRoot)
总结:
根据xml标签名称生成View,非public方法
View createViewFromTag(View parent, String name, Context context, AttributeSet attrs, boolean ignoreThemeAttr)
大概流程:
public final View createView(String name, String prefix, AttributeSet attrs)
总结:通过 类加载器 实现
void rInflate(XmlPullParser parser, View parent, Context context, AttributeSet attrs, boolean finishInflate)
rInflate方法是一个递归的方法,会将解析出来的View作为root(父View),继续进行子节点的解析,直到无法解析,即以下情况:
详细介绍
demo
什么是Inflation
inflation in.fla.tion[In`flєʃən;
inˋflєiʃn]《inflate 的名词》名词1 (U)膨胀,充气2 (U)自满,得意; 夸张3‘经济’通货膨胀【同义字】inflation 货币贬值,物价上涨deflation通货紧缩,物价持续性下跌reflation使物价回稳,景气回升,使物价适度上升
android中的“inflate”是什么意思?
inflate的作用就是将一个用xml定义的布局文件查找出来,注意与findViewById()的区别,inflate是加载一个布局文件,而findViewById则是从布局文件中查找一个控件。
1、获取LayoutInflater对象有三种方法
LayoutInflater inflater=LayoutInflater.from(this);
LayoutInflater inflater=getLayoutInflater();
LayoutInflater inflater=(LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
2、关于LayoutInflater类inflate(int resource, ViewGroup root, boolean attachToRoot)



