Introduction of the View class

The View class is the base class for various components in Android

Views represent various views displayed on the screen

The View structure of a View

View Base – Color

Color pattern

ARGB8888: four-channel high precision (32 bits) ARGB4444: four-channel low precision (16 bits) RGB565: Screen default mode (16 bits) Alpha8: Transparent channel only (8 bits)

Color definitions

A (Alpha) : transparency, transparency 0 (0* 00), opacity 255* (0*ff) RGB: red, green, blue respectively

Methods to create colors

Java

int color = Color.GRAY; // gray int color = color.argb (127,255,0,0)// translucent red int color = 0xaaff0000;Copy the code

xml

File: /res/values/color. XML < color name ="red" >#ff0000< /color> #f00 // High precision - no transparent channel red # aAFF0000Copy the code

Methods that reference colors

java

int color = getResoures().getColor(R.color.mycolor); int color = getColor(R.color.mycolor); //API 23 and aboveCopy the code

xml

   < style name="Apptheme" parent="Theme.AppCompat.Light.DarkActionBar">  
   < item name = "colorPrimary">@color/red</item>  
    < /style>
    
    android:background="@color/red"
    android:background="#ff0000" 
Copy the code

View base – position parameters

Top, left, right, bottom width = right-left height = bottom-top

To obtain

Left = getLeft () to obtain the View itself on the left to his father right layout on the left side of the distance = getRight () to obtain the View itself to its parent layout on the right the right distance from the top = getTop (access to View its top edge to its parent layout of the top edge of the distance Bottom =getBottom(Gets the distance from the bottom edge of the View itself to the top edge of its parent layoutCopy the code

TranslationX, translationY: The offset of the top left corner of the Veiw relative to the parent container x = left + translationX y = top + translationY

View base – Coordinate system

Gets the width and height of the screen area

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width=metrics.widthPixels;
int height= metrics.heightPixels;
Copy the code

Gets the width and height of the App area of the application

 Rect rect = new Rect();
 getWindow.getDecorView.getWindowVisibleDisplayFrame(rect);
Copy the code

Gets the status bar height

 Rect rect = new Rect();
 getWindow.getDecorView.getWindowVisibleDisplayFrame(rect);
 int statusBarHeight = rect.top;
Copy the code

Get View layout area width and height

 Rect rect = new Rect();
 getWindow.findViewById(window.ID_ANDROID_CONTENT).getDrawingRect(rect);
Copy the code

View’s coordinate system relative to the parent control

The differences between get and getRaw in MotionEvent are as follows: evet.getx (): the touch point is relative to the component coordinate system. Evet.getrawy (): the touch point is relative to the screen default coordinate system

GetHeight (), getWidth()

The View of sliding

View sliding can be implemented in many ways, let’s introduce one by one:

Use the scrollTo/scrollBy

Use animation

Use the LayoutParams

Use the Layout

Use offsetLeftAndRight() with offsetTopAndBottom()

ScrollTop, offsetHeight and offsetTop attributes

Several related attributes in the title are widely used in web pages, especially in motion frames. However, it is difficult to master some attributes due to mixed concepts or browser compatibility problems. Here is how to use the related attributes. See below:


OffsetLeft attribute: This attribute and offsetTop principle is the same, but the orientation is different, there is no more explanation here.

OffsetWidth property: This property can get the width of the element, the width value is: element content + inside margin + border. Margins and scroll bars are not included. The return value is an integer in pixels. This property is read-only.

OffsetHeight property: This property can get the height of the element, the width value includes: element content + inside margin + border. Margins and scroll bars are not included. The return value is an integer in pixels. This property is read-only.

ClientWidth property: This property returns the width of an element, the content of the element + the inner margin. Excluding borders, margins, and scrollbar sections. The return value is an integer in pixels. This property is read-only.

ClientHeight: This property returns the height of an element. The value is: the content of the element + inner margin. Excluding borders, margins, and scrollbar sections. The return value is an integer in pixels. This property is read-only.

ScrollLeft property: This property gets or sets the distance from the left of the object to the left of the object in the current window display range, that is, the distance that the element is pulled to the left by the scroll bar. The return value is an integer in pixels. This property is read and write

ScrollTop property: This property gets or sets the distance between the top of the object and the top edge of the object in the current window, that is, the distance by which the element scroll bar is pulled down. The return value is an integer in pixels. This property is read and write.

ScrollHeight property: This property gets the actual size of the object.

Use animation

Use animations. We can animate a View to pan, and a pan is a slide. The translationX and translationY properties of the View can be animated. The translationX and translationY properties of the View can be animated as well as the traditional View animation. If the property animation is used, in order to be compatible with versions below 3.0, The open source animation library nineoldandroids is required.

<? The XML version = "1.0" encoding = "utf-8"? > <set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" android:zAdjustment="normal">  <translate android:duration="100" android:fromXDelta="0" android:fromYDelta="0" android:interpolator="@android:anim/linear_interpolator" android:toXDelta="100" android:toYDelta="100"></translate> </set>Copy the code

This animation can move a View 100 pixels from its original position to the lower right corner in 100ms.

Use the LayoutParams

LayoutParms are easier to understand. For example, if we want to shift a Button 100px to the right, we simply increase the size of the marginLeft parameter in the Button’s LayoutParams by 100px. In another case, to move the Button, we can also place an empty View to the left of the Button. The default width of the empty View is 0. When we need to slide the Button to the right, we just need to reset the width of the empty View. When the width of the View increases (assuming that the parent container of the Button is a horizontal LinearLayout), the Button will be automatically squeezed to the right, which indirectly achieves the effect of the View translating to the right. How do I reset a View’s LayoutParams? Very simple, as follows:

scrollTo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) scrollTo.getLayoutParams(); layoutParams.leftMargin +=100; // scrollTo.requestLayout(); scrollTo.setLayoutParams(layoutParams); }});Copy the code

Use the Layout

As we know, when the View is drawn, the onLayout() method is called to set the display position. We can also change the View’s left, top, right, and bottom attributes to control the View’s coordinates. I’m not going to do it here, but it’s not very common, so just know.

Comparison of various sliding modes

ScrollTo /scrollBy is a native method provided by the View. It is specially used for sliding the View. It can easily achieve sliding effects and does not affect the click events of internal elements, but its disadvantages are obvious: It can only slide the contents of the View, not the View itself.

Look at animation, through animation to achieve View sliding, this is divided into two cases, if it is Android 3.0 and the use of attribute animation, then this way has no obvious disadvantages; If you animate a View or animated a property before Android 3.0, you cannot change the properties of the View itself. In practice, animation for sliding is appropriate if animated elements do not need to respond to user interaction, otherwise it is inappropriate. But animation has an obvious advantage, that is, some complex effects must be animated to achieve.

Finally, let’s take a look at the layout change method. It has no obvious disadvantages except that it is more troublesome to use. Its main objects are some interactive views, because these views need to interact with the user, and it would be problematic to implement them directly through animation.

For the above analysis, let’s make a summary, as follows:

ScrollTo /scrollBy: Simple operation, suitable for sliding the content of View; Animation: simple operation, mainly suitable for View without interaction and achieve complex animation effects to change layout parameters: slightly complex operation, suitable for interactive View.

The VIew animation

An overview of the

Android animation can be divided into three types: View animation, frame animation and property animation. Mainly View animation for a simple summary and introduction, in fact, frame animation also belongs to a View animation, but it and shift, rotation and other common View animation in the form of expression is slightly different. View animation is a kind of progressive animation by constantly changing the image of the object in the scene (translation, scaling, rotation, transparency) to produce animation effect, and View animation supports customization. The action object of View animation is View, which supports four animation effects, namely pan animation, zoom animation, rotation animation and transparency animation. As mentioned above, frame animation also belongs to View animation. In order to better distinguish these four transformations and frame animation, in this article, if there is no special explanation, then the View animation mentioned refers to these four transformations, and frame animation will be introduced separately later.

View animation classification

The four transformation effects of View Animation correspond to the four subclasses of Animation: TranslateAnimation, ScaleAnimation, RotateAnimation and AlphaAnimation, as shown in the following table. These four animations can be defined in XML or created dynamically in code. For View animations, XML is recommended because XML is more readable.

<? The XML version = "1.0" encoding = "utf-8"? > <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@[package:]anim/interpolator_resource" android:shareInterpolator=["true" | "false"]> <alpha android:fromAlpha="float" android:toAlpha="float"/> <scale android:fromXScale="float" android:toXScale="float" android:fromYScale="float" android:toYScale="float" android:pivotX="float" android:pivotY="float"/> <translate android:fromXDelta="float" android:toXDelta="float" android:fromYDelta="float" android:toYDelta="float" /> <rotate android:fromDegrees="float" android:toDegrees="float" android:pivotX="float" android:pivotY="float" /> <set> ... </set>Copy the code

The AnimationSet tag represents a collection of animations, corresponding to the AnimationSet class. It can contain several animations, and it can nest other collections of animations inside. Its two properties are as follows:

  android:interpolator    
Copy the code

Represents the interpolator used by the animation set, the interpolator affects the speed of the animation, such as non-uniform animation needs to control the animation playback process through the interpolator. This property can not specified, the default for @ android: anim/interpolator_resource, namely accelerated interpolator. Android: shareInterpolator indicates whether the animation of a set of collection and share the same interpolator. If the collection does not specify an interpolator, the child animations need to specify an interpolator separately or use default values. The tag represents a pan animation, corresponding to the TranslateAnimation class, which can animate a View in both horizontal and vertical directions. Its properties are as follows:

  • Android :fromXDelta —- represents the starting value of X, such as 0;
  • Android :toXDelta —- indicates the end value of X, such as 100;
  • Android :fromYDelta —- indicates the starting value of Y.
  • Android :toYDelta —- indicates the end value of Y.

The tag represents the zoom animation, corresponding to the ScaleAnimation, which can make the View zoom in and out of animation. Its set of properties have the following meanings:

  • Android :fromXScale —- The starting value of horizontal scaling, such as 0.5;
  • Avandroid :toXScale —- End value of horizontal scaling, such as 1.2;
  • Android :fromYScale —- Start value of vertical scaling;
  • Android :toYScale —- End value of vertical scaling;
  • Android :pivotX —- The x-coordinate of the zoom axis, which affects the zoom effect;
  • Android :pivotY —- The Y coordinate of the zoom axis, which affects the zoom effect;

Mentioned the concept of axis point, for example, by default axis point is the center of the View, at this time in a horizontal direction to zoom in words will lead to the View to the left and right two directions at the same time to zoom in, but if the right boundary of the set axis point of View, then the View will only to the left to zoom in, or to the right to zoom in.

The tag represents the rotation animation, corresponding to RotateAnimation, which can animate the View with rotation. Its properties mean the following:

  • Android :fromDegrees —- Rotation Angle, such as 0;
  • Android :toDegrees —- Rotation end Angle, such as 180;
  • Android :pivotX —- The X coordinate of the pivot point;
  • Android :pivotY —- The y coordinate of the pivot point; There is also the concept of pivot points in rotation animation, which also affects the specific effect of rotation. In rotation animation, the pivots act as the axis of rotation, i.e. the View is rotated around the pivots.

The tag represents the transparency animation, corresponding to AlphaAnimation, which can change the transparency of a View. Its properties have the following meanings:

  • Android :fromAlpha —- indicates the starting value of transparency, such as 0.1;

  • Android :toAlpha —- indicates the end value of transparency, such as 1; The XML format of the View animation was introduced above. In addition to the properties described above, View animations have some common properties, as follows:

  • Android :duration —- Animation duration in milliseconds;

  • Android :fillAfter —- Whether the View stays at the end position after the animation ends. True indicates that the View stays at the end position. False indicates that the View does not stay.

Patch animation

Steps:

1. Create the animation effect XML file in the RES /anim directory 2. Set different animation parameters according to the syntax of different animation effects 3. Create an Animation object in a Java class and play the Animation: or create an Animation object in a Java class and play it

The public properties of the animation effect
  • Duration: animation duration (ms), must be set for animation to be effective
  • StartOffset: Time interval between animations (ms)
  • FillBefore: Set bit true to be applied before animation conversion begins. Default is true
  • FillAfter: Set to true, animation conversion is applied after the animation ends, default is false
  • FillEnabled: indicates whether to apply the fillBefore value. The value of fillAfter is not affected. The default value is true
  • RepeatMode: Select the animation playback mode, restart positive sequence playback, reverse reverse playback, default restart
  • RepeatCount: number of repetitions (animation playback times = playback times +1), infinite infinite repetitions
  • Interpolator: interpolator, which affects the playback speed of an animation
The implementation of animation

1./res/anim Settings: alpha, scale, translate, rotate

  • AlphaAnimation: transparency
  • ScaleAnimation: zoom
  • TranslateAnimation: translation
  • Rotation RotateAnimation:
Loading way
1. Load the configuration file and play the animation
Animation translateAnimation = AnimationUtils.loadAnimation(this,R.anim.view_translate_animation);  
tvView.startAnimation(translateAnimation);
Copy the code
2. Dynamic creation
Animation translateAnimation = new translateAnimation (0,500,0,500); translateAnimation.setDuration(3000); tvView.startAnimation(translateAnimation);Copy the code

The frame of animation

Frame animation is a sequence of predefined images, similar to movie playback. Unlike View animation, the system provides another class AnimationDrawable to use frame animation. The use of frame animation is relatively simple. First you need to define an AnimationDrawable in XML, as shown below:

// res/drawable/frame_animation.xml <? The XML version = "1.0" encoding = "utf-8"? > <animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/image1" android:duration="500"/> <item android:drawable="@drawable/image2" android:duration="500"/> <item android:drawable="@drawable/image3" android:duration="500"/>Copy the code
   TextView textView = findViewById(R.id.mTextView);
   textView.setBackgroundResource(R.drawable.frame_animation);
   AnimationDrawable drawable = (AnimationDrawable) textView.getBackground();
   drawable.start();
Copy the code

Frame animation is easy to use, but it is more likely to cause OOM, so avoid using too many large images when using frame animation.

Property animation -0bjectAnimator

ValueAnimator (ValueAnimator) : ValueAnimator (ValueAnimator) : ValueAnimator (ValueAnimator) : ValueAnimator (ValueAnimator) ObjectAnimator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator: animator

The second String property argument in 0bjectAnimator.offloat () can be passed to alpha, rotation, trans lationX, scaleY, etc ObjectAnimator is a class that uses get/set methods to find the name of an object’s property. ObjectAnimator is a class that uses any property of any object, so you can customize the property of an object











Setting up the XML file
  <objectAnimator
  xmlns: android="http: //schemas. android. com/apk/res/android"
  android : propertyName=" alpha"
  android : valueFrom= "1"
  android:valueTo="o"
  android:valueType="floatType" />
Copy the code
Start in Java
 Animator animator = AnimatorInflater. loadAnimator( context: this, R. animator.set_ object_ animation);
 animator .setTarget( btnValue);
 animator .start();
Copy the code
PropertyValuesHolder
 PropertyValuesHolder p1 = PropertyValuesHolder . ofFloat( "translationX", 0, 200f );
 PropertyValuesHolder p2 = PropertyValuesHolder .ofFloat("rotation", 0, 200f);
 PropertyValuesHolder p3 = PropertyValuesHolder. ofFloat("translationY", 0, 200f);
 ObjectAnimator . ofPropertyVa luesHolder(point, p1, p2, p3). setDuration(1000).start();
Copy the code
An abbreviation for property animation
 btnValue . animate( ). alpha(0f).x(500).y(500);
 btnValue . animate( ).alpha(0f) . setDuration( 1000). setInterpolator( new BounceInterpolator( ));
Copy the code

Composite animation -AnimatorSet

AnimatorSet class: implements the function of combining animations

Animatorset. play(Animator anim): Play the current animation animatorSet. after(long delay): Execute animatorSet. with(Animator anim): Execute animatorSet. after(Animator anim): Animatorset. before(Animator anim): Inserts an existing animation before the incoming animation

AnimatorSet animatorSet = new AnimatorSet( ); animatorSet . play( translationX) . with( rotation). before( scaleX); animatorSet . setDuration( 5000 ); animatorSet.start();Copy the code

Common problems with animation

Some beautiful effects can be achieved through animation, but in the use of the process, also need to pay attention to some things, mainly divided into the following categories:

OOM problem This problem mainly appears in the frame animation, when the number of pictures is large and the picture is very easy to appear OOM, this in the actual development should pay special attention to, try to avoid the use of frame animation. In the property animation, there is a kind of infinite loop animation. This kind of animation needs to stop when the Activity exits, otherwise the Activity cannot be released, resulting in memory leakage. After verification, it is found that the View animation does not have this problem. Compatibility problems Animation has compatibility problems on systems below 3.0, and may not work properly in some special scenarios. Therefore, adaptation work is required. A View animation animates the View image and does not really change the state of the View. Therefore, sometimes the View cannot be hidden after the animation is completed, that is, setVisibility(view.gone) will fail. This can be resolved by simply calling View.clearAnimation () to clear the view animation. Do not use PX when animating, use DP as much as possible, using PX will result in different effects on different devices. Animation element interaction moves the view (pan), and on systems prior to Android3.0, neither view animation nor property animation can trigger the click event from the new position, while the old position can still trigger the click event. Even though the View is no longer visually present, when you move the View back to its original location, the original click event continues to take effect. Starting with 3.0, property animations trigger click events at moved locations, but View animations remain in place. Hardware acceleration You are advised to enable hardware acceleration to improve animation smoothness.

Custom animated View

In addition to the four View animations provided by the system, we can also customize the View animations. To derive a new Animation, we simply inherit the Animation abstract class and override the Initialize and applyTransformation methods. In the Initialize method, we do some initialization. The matrix transformation of the response can be carried out in applyTransformation. In many cases, Camera is needed to simplify the matrix transformation process. It is complicated because the process of defining View animation is mainly the process of matrix transformation, and matrix transformation is a mathematical concept, if you are not familiar with this aspect of knowledge, you will find this process is more complicated.

In general, custom View animations are rarely used in real development. Here is an example of a custom View animation. This example comes from a custom View animation in Android ApiDemos. Rotate3Animation extends Animation {Public class Rotate3dAnimation extends Animation {Public class Rotate3dAnimation extends Animation {public class Rotate3dAnimation extends Animation {public class Rotate3dAnimation extends Animation {public class Rotate3dAnimation extends Animation {

private final float mFromDegrees; private final float mToDegrees; private final float mCenterX; private final float mCenterY; private final float mDepthZ; private final boolean mReverse; private Camera mCamera; public Rotate3dAnimation(float fromDegrees, float toDegrees, float centerX, float centerY, float depthZ, boolean reverse) { this.mFromDegrees = fromDegrees; this.mToDegrees = toDegrees; this.mCenterX = centerX; this.mCenterY = centerY; this.mDepthZ = depthZ; this.mReverse = reverse; } @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mCamera = new Camera(); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { final float fromDegrees = mFromDegrees; float degrees = fromDegrees + ((mToDegrees - fromDegrees) * interpolatedTime); final float centerX = mCenterX; final float centerY = mCenterY; final Camera camera = mCamera; final Matrix matrix = t.getMatrix(); camera.save(); If (mReverse) {camera. Translate (0.0f, 0.0f, mDepthZ * interpolatedTime); } else {camera. Translate (0.0f, 0.0f, mDepthZ * (0.0f-interpolatedTime)); } camera.rotateY(degrees); camera.getMatrix(matrix); camera.restore(); matrix.preTranslate(-centerX, -centerY); matrix.postTranslate(centerX, centerY); }}Copy the code

Interpolators and estimators

interpolator

Definition: an interface function: set the change rule of the attribute value from the initial value to the end value (such as uniform speed, acceleration & deceleration, etc., which determines the mode of animation effect change, such as uniform speed change, acceleration change, etc.) Realize nonlinear movement (animation change rate is not static, such as acceleration & deceleration motion belongs to nonlinear motion) of animation effects Special remind: the system default interpolator is AccelerateDecelerateInterpolator, namely first accelerated after the slowdown

The specific application

1. Set in Java code:

Button Button = (Button) findViewById(R.i.b.button); Animation alphaAnimation = new alphaAnimation (1, 0); alphaAnimation.setDuration(3000); // Step 2: Create the corresponding Interpolator class object Interpolator overshootInterpolator = new overshootInterpolator (); / / step 3: to animation set interpolator alphaAnimation. SetInterpolator (overshootInterpolator); // step 4: set the animation object & startAnimation button.startanimation (alphaAnimation);Copy the code

2. Set in XML:

<? The XML version = "1.0" encoding = "utf-8"? > < scale XMLNS: android = "http://schemas.android.com/apk/res/android" / / through setting interpolator resource ID Android: interpolator = "@ android: anim/overshoot_interpolator" android: duration = "3000" android: fromXScale = "0.0" Android :pivotY="50%" Android :toYScale="2" Android :toYScale="2" />Copy the code

System built-in interpolator type

Corresponding Java class Resource ID role
AccelerateInterpolator @android:anim/accelerate_interpolator Animation speeds up
OvershootInterpolator @android:anim/overshoot_interpolator Go through the animation quickly, beyond and back to the end style
AccelerateDecelerateInterpolator @android:anim/accelerate_decelerate_interpolator Speed up and then slow down
AnticipateInterpolator @android:anim/anticipate_interpolator Back up and then speed up
AnticipateOvershootInterpolator @android:anim/anticipate_overshoot_interpolator Step back and speed up, cross the finish line and come back
BounceInterpolator @android:anim/bounce_interpolator Last stage pinball effect
CycleInterpolator @android:anim/cycle_interpolator Periodic motion
DecelerateInterpolator @android:anim/decelerate_interpolator Slow down
LinearInterpolator @android:anim/linear_interpolator LinearInterpolator uniform

Valuation is

Definition: An interface that interpolates a change in a property value from an initial value to an end value. The Interpolator determines a rule of constant velocity, Interpolator, or trend of a value. The following specific change values are given to the estimator to pay special attention to: The estimator attribute animation specific application scenarios: to assist the interpolator to achieve nonlinear motion animation effects

The specific use

Implemented in Java

Evaluator(myView2, "height", new Evaluator(), 1,3); // FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: FloatEvaluator: ArgbEvaluator: ArgbEvaluator is argGB. ArgbEvaluator is argGB. ArgbEvaluator is argGBCopy the code

The type of estimator built into the system

type instructions
IntEvaluator Integer property value.
FloatEvaluator Floating point property value.
ArgbEvaluato Hex color property value.
TypeEvaluator User-defined interface for property values, such as object property values of types other than int, float or color, you must implement this interface to define your own data types.

Principles of the event distribution mechanism

What is an event distribution mechanism? Event distribution is the process of finding an appropriate control on the screen to handle an event when it occurs. Because there are so many controls on an interface, there is always a need to find a suitable way to handle an event. This process is called the event dispatch mechanism.

Event distribution objects: Touch event, Touch details encapsulated in the MotionEvent object

Activity -> ViewGroup -> View

DispatchTouchEvent (): dispatches (passes) the click event, onTouchEvent() is called when the click event is passed to the current Vi ew: Handles the click event, called within dispatchTouchEvent()

onInterceptTouchEvent(): ** From which object the click event is emitted, through which object it passes, which object it reaches, and the order in which the event is distributed: DisptachTouchEvent -> setOnTouchListener -> onTouchEventonClick, onLongClick

The event type The specific action
MotionEvent.ACTION_DOWN Press View(Start of all events)
MotionEvent.ACTION_UP Press View(corresponding to DOWN)
MotionEvent.ACTION_MOVE Slide the View
MotionEvent.ACTION_CANCEL End event (non-human cause)

Click events always start with the Activity’s event distribution process as shown below

The event distribution mechanism of a ViewGroup

View event distribution mechanism