Before understanding ViewRoot, DecorView & Window, look at the structure View of chromatography.
- DecorView as the topmost Window View entire interface.
- DecorView only one child is LinearLayout. Representative of the Window interface, includes the notification bar, title bar, display the contents of three bar area.
- There are two LinearLayout FrameLayout children.
(20) for the title bar display. Only a TextView display application
(21) for the content bar display. It is the setContentView () method of loading a layout interface, added thereto.
A .VeiwRoot
1 Introduction
2 Special Note:
// 在主线程中,Activity对象被创建后:
// 1. 自动将DecorView添加到Window中 & 创建ViewRootImpll对象
root = new ViewRootImpl(view.getContent(),display);
// 3. 将ViewRootImpll对象与DecorView建立关联
root.setView(view,wparams,panelParentView)
Two .DecorView
1. Definitions
Top View, i.e. the root node of the tree view Android; FrameLayout also the subclass.
2. Role
Load & display layout. Event View layers have to go through DecorView, and then passed to the View.
3. Special Note
Containing a vertical direction LinearLayout, divided into two parts:
= title bar (TitleBar) (1)
(2) = content column (content)
In Activity by setContentView () into the layout file set is actually being added to the contents column, becoming the only son View = id for the content of FrameLayout in.
NOTE: Get setContentView () View code is provided as follows:
// 在代码中可通过content得到对应加载的布局
// 1. 得到content
ViewGroup content = (ViewGroup)findViewById(android.R.id.content);
// 2. 得到设置的View
ViewGroup rootView = (ViewGroup) content.getChildAt(0);
Three .Window
Four .Activity
V. Relations between
Relations ViewRoot, DecorView, Window and Activity is very important.