Foreword
- Custom View is the principle of Android developers need to know basis, before Understanding Custom View, you need to have some knowledge reserves.
- Today, it will be fully resolved on the basis of Custom View: ViewRoot, DecorView & Window , hope you like it.
table of Contents
1. ViewRoot
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 Definitions
Top View, i.e. the root node of the tree view Android; subclass also FrameLayout
2.2 Role
Load & display layout. Event View layers have to go through DecorView, and then passed to 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 son View = id for the content ofFrameLayout
the
// 在代码中可通过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.
5.1 summary
The relationship between 5.2
6. Summary
- In this paper a comprehensive analysis on the basis of Custom View: ViewRoot, DecorView & Window ,
- About Custom
View
other articles of:
(1) Custom View basis - most understandable Custom View principles Series
(2) Customize View Measure process - most understandable Custom View principles Series
(3) Custom View Layout Process - the most straightforward principle series custom View
(4) customize View Draw process - the most straightforward principle series custom View - Next, I will continue to View from the application of the definition to explain, are interested can continue to focus on Android development Carson_Ho notes
Please thumbs up! Because you agree / encouragement is the greatest power of my writing!
Read related articles
Android event distribution mechanism to explain: the history of the most comprehensive and easy to understand
Android development: the most comprehensive and understandable Android screen adaptation solutions
Android Development: the most complete history of Android push messaging solution for
Android developers: the most comprehensive and understandable Detailed Webview
Android development: JSON profile and most comprehensive analytical method!
Android four major components: Service service history of the most comprehensive analysis of
Android four components : BroadcastReceiver history of the most comprehensive analysis
Welcome concern Carson_Ho Jane book!
From time to time to share about Android development dry goods, the pursuit of short, flat, fast , but does not lack depth .
Reproduced in: https: //www.jianshu.com/p/28d396a0f05f