Android simultaneously presses multiple buttons and Android multiple buttons
Keywords: multi-touch, control, button, Android, and press [maybe this will help more people retrieve ??]
I haven't written a blog post for a long time. Recently, I encountered such a problem during my graduation project. I have never encountered such a problem before. I 've taken some detours and now I want to write down my records.
In the process of Baidu, I did not see any relevant answers, but it is still a detour. Next, let's go to the blog topic.
Problem: implement the "Baidu handle" button and click it at the same time, that is, one button cannot be clicked, And the other button is clicked.
In fact, many people have the first reaction: Isn't this something android can do? Then I vowed to write a Demo and found that it was actually not working.
Everyone listens to the touch event and then processes it. You can find that the touch of the other buttons will not be executed when you press the first button and then press another button, instead, they all go through the processing process in the touch of the first button.
Then I went to Baidu, and Baidu answered your question with multi-touch, and a bunch of information clearly told you to listen to a few fingers and click the screen .... at this time, the answer in your mind is basically finalized, and then begin to write the multi-touch processing process.
Finally, you will find that it is very troublesome for you to handle it by yourself. You need to use the x and y of your fingers to determine what the currently clicked control is. Then you may encounter a problem where the last finger bounce event cannot be monitored.
After talking about this, you only need to add a row of attribute in the parent layout of these buttons.
Android: splitMotionEvents = "true"
Some people say that this parameter indicates whether global multi-touch is supported. If it is false, it is not supported. If it is true, it is supported.
I think this is to see if touch events are diverted to various corresponding controls.
Sometimes it becomes a time cost if you know little about it !!