我转发的,觉得不错,留作日后参考-----------------------------------------------------写在前面的话:本系列主要是学习sundy的Android深入浅出视频中的一些记录,心得。方便自己以后查阅。也供大家查看。欢迎交流,补充。
一般作为面试题(有些有答案,有些没有。问题一般从sundy老师思维导图中摘录,答案并非唯一标准,仅供参考):
 
1、Activity , Window和View的关系是什么?跟踪Activity的源码就会发现:
Activity.attch() -> PolicyManager -> Policy -> PhoneWindow -> mLayoutInflater.inflate()&mContentParent.addView()
这只是一个简单的跟踪过程描述。通过跟踪源代码,就可以很清晰的看出他们三者的关系。 Activity像一个工匠(控制单元),Window像窗户(承载模型),View像窗花(显示视图)
LayoutInflater像剪刀,Xml配置像窗花图纸。1)一个Activity构造的时候会初始化一个Window,准确的说是PhoneWindow。
2)这个PhoneWindow有一个“ViewRoot”,引号是说其实这个“ViewRoot”是一个View或者说ViewGroup,是最初始的根视图。
3)“ViewRoot”通过addView方法来一个个的添加View。比如TextView,Button等
4)这些View的事件监听,是由WindowManagerService来接受消息,并且回调Activity函数。比如onClickListener,onKeyDown等2、Activity是android的显示视图么?
不是3、LayoutInflater是做什么的 ? layoutInflater.inflater()做什么的?
一般来讲,我们用LayoutInflater做一件事:inflate。inflate这个方法总共有四种形式,目的都是把xml表述的layout转化为View。
This class is used to instantiate layout XML file into its corresponding View objects . It is never be used directly -- use 
getLayoutInflater() or getSystemService(String)getLayoutInflater() or getSystemService(String) to retrieve a standard 
LayoutInflater instance that is already hooked up to the current context and correctly configured for the device you are 
running on