Android Window: easy to learn and organize 1. androidwindow
1. Relationship between Activity, Window, and View
The Android Graphical User Interface (GUI) follows the general rules of GWES (Graphic window Event System) and manages User input (Event Management) and System screen output (window and interface drawing.
In Android development, if you want to display an interface, you will first write an Activtiy subclass, so all of them are understood as Activity is an interface, which is a broad term. The system is responsible for creating development and writing Activity subclasses. Activity creation creates a Window object (usually PhoneWindow), and a View object (DecorView) is added during Window creation ). Therefore, the relationship between the three is Activity-> Window-> View. The following briefly describes the main responsibilities of the three (see the three official documents ):
Activity: the boss of an application display interface. It is not responsible for Screen Display and is mainly used for interaction with the Android system. Window: displays the layout (whether multiple windows are displayed at the upper or lower level, or even at the upper or lower level), display level, and event processing. View: controls how to draw events in a specific View area and View area.
Ii. Window System
Windows Management for Android is in Client/Server (C/S) mode.
ClientActivity opens a session (opens the IWindowSession AIDL Interface) and adds the Window to WindowManager through this interface.
Server adds a window to WindowManager
Windows Management erserviceandroid design considerations:
Window z-order Management (how to overlay Windows)
Calculation of the activity window and notification of changes
Window owner (which application belongs)
Input Method management
Iii. Window Type and hierarchy
WindowManagerService-> IWindow <-ViewRoot (View variable and token are used for IPC Communication)
Window type. The larger the int value, the closer it is to display
Window Type |
Creation Method |
Value Range |
Application Window |
The Activity is created internally. |
1 ~ 99 |
Subwindow |
Created by the parent window |
1000 ~ 1999 |
System window |
The system determines that only one layer is displayed. |
2000 ~ 2999 |
Reference: Android core analysis (12) ----- basic architecture of Android GEWS Window Management
Android core analysis (13) ----- Android GWES-Android Window Management
Analysis of Android kernel by Ke Xinnian's chapter 8th window creation process Chapter 2 Working Principle of WindowManagerService