Android simultaneously presses multiple buttons and Android multiple buttons

Source: Internet
Author: User

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 !!


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.