In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the Android event distribution mechanism and conflict example analysis, the article is very detailed, has a certain reference value, interested friends must read!
Common sliding conflict scenarios!
Currently common sliding conflicts can be divided into the following three main types to summarize:
The sliding direction of the external View is inconsistent with that of the internal View. The sliding direction of the internal View and the external View is ** perpendicular to each other. ** For example, Scroll View nested View Pager, as shown in Figure 1-1;
The sliding direction of the outer View and the sliding direction of the inner View are consistent, and the sliding directions of the inner View and the outer View are ** parallel to each other, ** for example, Scroll View nested RecyclerView, as shown in Figure 1-2;
The external sliding direction and the internal sliding direction are both the same and vertical, that is, the combination of the above two situations, which is a relatively complicated situation, as shown in Figure 1-3.
Common sliding conflict processing ideas!
Sliding conflicts look tricky, especially when they are nested several times like in Scenario 3.
However, no matter how complex the sliding conflict is, it mainly involves the distribution and interception of some touch events. There are certain processing rules in it. We can choose the appropriate method to handle it according to the rules:
Two basic ways of conflict resolution
(1). external interception method
That is, rewrite the onInterceptTouchEvent method of the parent container, and return the corresponding Boolean value according to whether the parent container needs to intercept the event. If the parent container needs to intercept the touch event, it returns true, and if it does not intercept, it returns false;
(2). internal interception
That is, the parent container does not intercept any event, but passes the corresponding event to the child element, and processes it according to whether the child element needs to consume this touch event. If the child element does not consume this event, it will be handed over to the parent container for corresponding processing. The child container needs to be processed as shown in Figure 2-2, and the parent container needs to be processed as shown in Figure 2-3.
At the same time, event conflict is also a must-have question in the first-line Internet factory. Let's see how many of these questions can you answer?
Tell me about your understanding of the event distribution mechanism. (Ali interview real question)
What is the flow mechanism for down and move events? (Tencent interview real question)
Please give an example of how to quickly find a solution to an incident conflict. (Byte interview)
How to resolve ScrollView and RecyclerView conflicts? (Baidu interview)
Therefore, the skills to resolve conflicts are also the essence that everyone needs to master!
However, if you learn through blog articles, you feel that you have learned after reading them. Once there is a problem of event conflict in the project, it is difficult to apply the knowledge points in the article to practical problems, and the biggest problem encountered by many developers in solving event conflicts is that it is difficult to find an entry point to solve the problem.
The above is "Android event distribution mechanism and conflict example analysis" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un