类图记录View_ViewGroup_Window
其中,View 和ViewGroup 是组合关系, View 依附在Window上,Window呈现给用户
1. DecorView
(1) DecorView 是android 隐藏的类(com.android.internal.policy), 由各个厂商自定义实现。
它是Window 上最顶层的View, 它也是FrameLayout的子类。(包括actionbar / content /navigation bar?)
/** @hide */
public class DecorView extends FrameLayout implements RootViewSurfaceTaker, WindowCallbacks {
(2) 获取DecorView实例
在Window 抽象类中定义接口 getDecorView():
Window.java
/**
* Retrieve the top-level window decor view (containing the standard
* window frame/decorations and the client's content inside of that), which
* can be added as a window to the window manager.
*
* <p><em>Note that calling this function for the first time "locks in"
* various window characteristics as described in
* {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}.</em></p>
*
* @return Returns the top-level window decor view.
*/
public abstract @NonNull View getDecorView();
参考源码:com.android.internal.policy
包 : android.view
2. Window结构:
Application --->
Activity --->
Window Manager --->
Window --->
Surface --->
Canvas --->
View Root --->
View Group --->
View --->
Bitmap/Open GL panel --->
Current Surface Buffer --->
Surface Flinger --->
Screen
参考:https://stackoverflow.com/questions/9451755/what-is-an-android-window
https://stackoverflow.com/questions/4576909/understanding-canvas-and-surface-concepts#answers