Introduction to Android Interface Architecture (Activity, PhoneWiondow, DecorView), activitydecorview
In an Android Application, the user interface is built through the View and ViewGroup objects. The child classes of all views become "widgets", and the Child classes of all viewgroups become "Layout ". The combination design mode is used between View and ViewGroup. As the top layer of the layout container class, ViewGroup can have View and ViewGrou
DecorView, androiddecorview
1. DecorView is the top View of the entire Window interface.
2. DecorView has only one child element, LinearLayout. Indicates the entire Window interface, including the notification bar, title bar, and content display bar.
3. LinearLayout contains two FrameLayout sub-elements.
(20) The title bar display interface. Only one TextView di
When using dialog, the following two errors are not shown12-11 17:47:49.776:e/windowmanager (11461): android.view.WindowLeaked:Activity testactivity has leaked window com.android.internal.policy.impl.phonewindow$decorview{42204800 v.e ..... R..... I. 0,0-640,164} that is originally added here12-11 17:47:50.666:e/androidruntime (11461): java.lang.illegalargumentexception:view= com.android.internal.policy.impl.phonewindow$
in a In Android applications, the user interface is built from view and ViewGroup objects. All The subclass of View becomes " Widget", and all ViewGroup subclasses become "Layout". The combination design pattern is used between the View and the viewgroup . ViewGroup as the topmost layer of the layout container class, the layout container can also have View and viewgroup. ViewGroup and View combination relationships such as:ViewGroup and view inheritance relationships such as:whenStartActivityt
Exception scenarios:
It is often necessary to process time-consuming work in applications, such as reading large files and accessing network resources. In order to avoid poor user experience caused by program death, we can solve this problem through
featureid) {final int flag = 1
Phonewindow classIn/frameworks/policies/base/phone/COM/Android/Internal/policy/impl/phonewindow. JavaNote: This class inherits from the window class, which is the specific implementation of the window class. That is, we can use this class to draw a window. In addition, this class contains a decorview object, which is the root view of all application windows (activity interfaces. In short, the phonewindow class encapsul
Policymanager class uses this member function to create a Phonewindow object for an activity component.The Phonewindow class inherits the window class, so its objects can be saved in the member variable Mwindow of the Activity class. The implementation of the Phonewindow class is shown in 5:Figure 5 Implementation of the Phonewindow classThe Phonewindow class has two important member variables Mdecor and mcontentparent, and their types are Decorview
Android Touch event Transfer Mechanism
Recently, I have always encountered problems with Android Touch events, such as sliding conflicts. I have also spent some time learning about the transmission mechanism of Android Touch events. I can always forget it every time I use it, simply sum up and write an article to avoid forgetting it later. In fact, there are a lot of articles about the transfer of Touch events on the Internet, but few of them are systematic, I wrote a simple demo and ran it. It
the z-order sequence list that stores the WindowState, and send the message to the IWindow server (IWindow. stub subclass), this IWindow. stub belongs to ViewRoot (this class inherits Handler and is mainly used to connect PhoneWindow and WindowManagerService), so the event is passed to ViewRoot. dispatchPointer.
Let's take a look at the dispatchPointer method of ViewRoot:
1 public void dispatchPointer(MotionEvent event, long eventTime,2 boolean callWhenDone) {3 Message msg =
directly find the subclass to see the concrete logical implementation of the Superdispatchtouchevent () method, and the only subclass of the window is Phonewindow, Let's take a look at Phonewindow's Superdispatchtouchevent () method.
public boolean superdispatchtouchevent (KeyEvent event) {return
mdecor.superdispatctouchevent (event);
}
Inside directly call the Decorview class Superdispatchtouchevent () method, perhaps many peo
Prepared for a while, always wanted to write an event distribution of the article summed up, this knowledge point is too important.
An application of the layout is rich, there are textview,imageview,button and so on, these child view of the outer layer there are viewgroup, such as Relativelayout,linearlayout. As a developer, we think, when clicked on a button, how did the Android system make sure that I ordered the button instead of the TextView? It then responds correctly to the button's Click
the mWindow member variable of the Activity class. Implementation 5 of the PhoneWindow class is shown below:
Figure 5 Implementation of the PhoneWindow class
The PhoneWindow class has two important member variables: mDecor and mContentParent. Their types are DecorView and ViewGroup. The member variable mDecor is used to describe its own window view, while the member variable mContentParent is used to describe the parent window view.
The
Activity is an Android ApplicationProgramAllows you to create a user interface on it, and provides APIs for users to process events, such as onkeyevent and ontouchevent. And maintain the application lifecycle. Activity itself is a huge carrier, which can be understood as the carrier of the application. If there is a wooden activity, the android application will not be able to run. Activitymanagerservice is responsible for maintaining the Instance Object of the activity and maintaining its status
are passed in layers, that is, the event is first passed to the root view Decorview, which is then passed down and eventually uploaded to the target view. If you add a custom viewgroup to the root view Decorview and its child view linearlayout, we can intercept the event in a custom ViewGroup to determine whether to turn off the soft keyboard.
Now that you want to add a custom viewgroup in the middle of
= generateLayout (mDecor); ......} through the mDecor object );.....}.....}
You can see that the DecorView is generated by using the generateDecor method. This DecorView is actually the root View of all application Windows:
public class DecorView extends FrameLayout implements RootViewSurfaceTaker, WindowCallbacks {...}
The mContentParent object is initialized i
BasisThe whole process is basically done in Phonewindow. First list the methods that will be used in it. As follows: It can be seen that it Mdecor for Decorview object protected Decorview Generatedecor () {return new Decorview (GetContext (),-1); }//findviewbyid () is as follows: Public View Findviewbyid (@IdRes int id) {return Getdecorview (). Findviewbyid
Android View system analysis (below), androidview
Android View parsing series:
Analysis of Android View system (I)
This section describes the basic knowledge of a View, sliding, elastic sliding, sliding conflict resolution, and event distribution.
Analysis of Android View system (below)
This article introduces the Framework layer principle of View, three steps and some advanced skills of View: measure, layout, and draw.
This section mainly introduces the lower part. The outline is as follows:
V
steps, check whether the decorview exists. If it does not exist, we need to create a decorview; in addition, we add the root layout to the decor view. Finally, we add the decorview to the phone window.
At this time, I began to think about it. Our root layout was added to the decor view, is a ing performed before being added to the decor view or a ing started aft
Android and androidsdkDecorView
During development, setContentView (R. layout. custom_layout) is usually called in onCreate () to implement the desired page layout. The page is attached to the window, and the DecorView is the top view of the window. In Android frameworks, classes related to Window view processing are mainly Window and Its Implementation class PhoneWindow.
Public class PhoneWindow extends Window implements MenuBuilder. callback {//...
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.