Disable multi finger touch in my app

android, android-emulator, android-fragments, android-intent, android-layout

Solution

For case: you have multiple buttons and you want make selected only one button. In parent (NOT ROOT, just parent of child) of buttons, in its xml params add

android:splitMotionEvents="false"

And that's it. Example:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:splitMotionEvents="false" <-----------!!!
    >

    <Button
    android:id="@+id/button_main_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button1" />

    <Button
    android:id="@+id/button_main_2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button2" />

    <Button
    android:id="@+id/button_main_3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="button3" />
</LinearLayout>

Btw. When you have 2 linearlayout with 3 buttons per layout, you should set this splitMotionEvents in that two layouts and also in parent of that 2 linearLayouts. Otherwise you will be able click only one button per layout (sum = 2 then). I hope you get it. :)

None of the other solutions didn't work for me or was too lame.

Problem

My app uses one Activity to host several fragments. Each time one fragment is shown on the phone screen.The view of each fragment consists of several image icons. Currently, user is able to press on two icons simultaneously with two fingers (with each fingure press on one icon). I want to disable this multi-touch feature on my app to allow only one icon press take effect at a time. I tried the following ways: Way 1: in my app theme, I added: ``` <item name="android:windowEnableSplitTouch">false</item> ``` Way 2: In Android Manifest xml, I added: ``` <uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" /> ``` Way 3: in my Activity: ``` @Override public boolean onTouchEvent(MotionEvent event) { if(event.getPointerCount() > 1) { System.out.println("Multitouch detected!"); return true; } else return super.onTouchEvent(event); } ``` Unfortunately, none of my solutions work. So, How can I disable multi-touch feature in my app??

Original source

Related problems