table of Contents
Brief introduction
- 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 applications
- (21) for the content bar display. It is the setContentView () method of loading a layout interface, added thereto.
table of Contents
1, VeiwRoot
1.1 Introduction
1.2, special attention
// 在主线程中,Activity对象被创建后:
// 1. 自动将DecorView添加到Window中 & 创建ViewRootImpll对象
root = new ViewRootImpl(view.getContent(),display);
// 3. 将ViewRootImpll对象与DecorView建立关联
root.setView(view,wparams,panelParentView)
2、DecorView
2.1, the definition of
Top View, i.e. the root node of the tree view Android; FrameLayout also the subclass.
2.2 Role
Load & display layout. Event View layers have to go through DecorView, and then passed to the View.
2.3 Special Note
Containing a vertical direction LinearLayout, divided into two parts:
- = On the title bar (titlebar)
- Under Column = content (content)
In
Activity
throughsetContentView()
into the layout file set is actually being added to the contents of the column, becoming the only childView = id
tocontent
theFrameLayout
middle.
注:获取setContentView()设置的View代码如下:
// 在代码中可通过content得到对应加载的布局
// 1. 得到content
ViewGroup content = (ViewGroup)findViewById(android.R.id.content);
// 2. 得到设置的View
ViewGroup rootView = (ViewGroup) content.getChildAt(0);
3、Window
4、Activity
5, the relationship between
Relations ViewRoot, DecorView, Window and Activity is very important.