Event distribution mechanismOne. Click event Propagation Path1. Click event TouchEvent first to reach activity, and then to the activity corresponding to the window, and then to Decorview, and then to the ID content of the ViewGroup, That is, we set the ViewGroup through Setcontentview to the last view. What we can control by programming is activity,viewgroup and
TouchEvent touch event mechanism in Android
When our Fingers click or slide on the Android screen, the touch event TouchEvent is triggered. In the App, ViewGroup and View have multi-level nesting. In the outermost layer, there are Activity and inner View, some viewgroups between Activity and View. To simplify the discussion, we assume that only one ViewGroup exists in an Activity and only one View exists in
Touch event TouchEvent is triggered when our fingers are clicked or slid on the Android screen. In the app, ViewGroup and view exist in multiple levels of nesting, in the outermost is activity, the most inner view, between activity and view is some viewgroup. To simplify the discussion, we assume that there is only one viewgroup in an activity, and that there is
Touch event Distribution
There are only two protagonists in Touch event distribution: ViewGroup and View. The Touch event of an Activity is actually a Touch event that calls its internal ViewGroup and can be processed as a ViewGroup directly.
In ViewGroup, ViewGroup can also
Event distribution is a very important mechanism in Android and is the basis for user interaction with the interface. This article will create a flowchart of event distribution by using the example print log, making it easier for everyone to understand the Android event distribution mechanism.
First, the necessary basic knowledge
1. Related methods
The methods associated with event distribution in Android include Dispatchtouchevent, Onintercepttouchevent, ontouchevent three methods, and event
There are only two main characters in touch event distribution: ViewGroup and view. The activity's touch event is actually called the ViewGroup touch event inside it, and can be treated directly as ViewGroup.View within the ViewGroup, ViewGroup can also be in other viewgroup
There are only two main characters in touch event distribution: ViewGroup and view. The activity's touch event is actually called the ViewGroup touch event inside it, and can be treated directly as ViewGroup.View within the ViewGroup, ViewGroup can also be in other viewgroup
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
Measure calculation process of View in Android
In Android, Veiw goes through three phases in sequence from memory to display on the UI: Traffic calculation-> Layout-> drawing, for details about the overall mechanism of View calculation, layout, and drawing, see the layout and Drawing Mechanism of View in Android. Volume is the basis of layout and drawing, so it is an important part. This article will analyze the View's quantitative calculation process from the source code perspective, which inv
boolean isLongpressEnabled () {} public boolean onTouchEvent (MotionEvent ev) {} public boolean onGenericMotionEvent (MotionEvent ev) {}}
With the introduction to the basic APIs of the above GestureDetector gesture tool class, we can use all kinds of tools without any special introduction.
Note:In fact, there are also GestureOverlayView gestures such as Gesture to create recognition classes, which are not described here as an extension.
View and ViewGroup
setcontentview ()
StreamProcess 1: mesarue () Process
Main function: calculate the actual size for the entire view tree, that is, set the actual height (corresponding attribute: mmeasuredheight) and width (corresponding attribute: mmeasurewidth ), the actual width and height of each view control are determined by the parent view and its own view.The call chain is as follows:The viewroot root object property mview (whose type is generally viewgroup) c
There are only two main characters in touch event distribution: ViewGroup and view. The activity's touch event is actually called the ViewGroup touch event inside it, and can be treated directly as ViewGroup.View within the ViewGroup, ViewGroup can also be in other viewgroup
:@OverridepublicvoidrequestDisallowInterceptTouchEvent(boolean b) { // Nope.}Swiperefreshlayout inherited from Viewgroup,requestdisallowintercepttouchevent is covered by the following code in ViewGroup: Public void requestdisallowintercepttouchevent(BooleanDisallowintercept) {if(Disallowintercept = = ((Mgroupflags flag_disallow_intercept)! =0)) {//We ' re already in the assume our ancestors is too
View event delivery for Android1. Basic knowledge(1) All touch events are encapsulated into Motionevent objects, including the position of the touch, the time, the history, and the first few fingers (multi-touch).(2) Event types are divided into Action_down, action_up, Action_move, Action_pointer_down, Action_pointer_up, Action_cancel, and each event is ACTION_ Down begins action_up end.(3) The handling of events includes three classes, namely, the transfer of--dispatchtouchevent () function, in
This time we are going deep into viewgroup, understanding the work of viewgroup, and will explain more about the view of the relevant knowledge. In order to be flexible in the future use of custom space beatings a step closer to the foundation. Want to have like-minded friends to explore, deep inside Android, in-depth understanding of Android.
First, what is ViewGroup
:
Viewpager = (Viewpager) Findviewbyid (R.id.viewpager);
Layoutinflater Inflater=getlayoutinflater ();
View1 = inflater.inflate (R.LAYOUT.LAYOUT1, null);
View2 = Inflater.inflate (r.layout.layout2,null);
VIEW3 = inflater.inflate (R.LAYOUT.LAYOUT3, null);
Viewlist = new arraylist
The initialization process is not very difficult, is to link the resources and variables layout, and finally add the instantiated view1,view2,view3 to the Viewlist3, Pageadapter--pageview adapteradapt
Compared with a key message, a touch message is also received by the viewrootimpl. windowinputeventreceiver instance. Different methods are executed after the message type is determined.The deliverpointerevent (.) method has the following differences:
The inputmanagerservice of the message retrieval module sends a touch message directly to the application without any internal preprocessing of WMS. In the latest version, the message is only executed when the screen is disabled.Interceptmotionbe
1. First of all, I understand the common sense that the View does not have an onInterceptTouchEvent event. However, ViewGroup has all three events. After the viewgroup inherits the View, a method called onIntercepTouchEvent is added.It can be seen from the literal meaning that onInterceptTouchEvent is used to intercept events, dispatchTouchEvent is used to distribute events, and onTouchEvent is used to proc
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.