Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable multi finger touch in my app [duplicate]

Tags:

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

like image 338
Leem.fin Avatar asked Oct 08 '12 07:10

Leem.fin


People also ask

How do I turn off multiple touch?

To prevent multi touch you should turn off splitMotionEvents or windowEnableSplitTouch attribute inside ViewGroup were buttons are located.

How do I turn on multiple touch on Android?

Introducing multi-touch That's called a "tap" gesture. Another gesture is called "drag". That's where you hold one finger on the screen and move it around, causing the content under your finger to scroll. Tap, drag, and a few other single-fingered gestures have always been supported in Android.

What is multi touch in Mobile?

A multi-touch gesture is when multiple pointers (fingers) touch the screen at the same time. This lesson describes how to detect gestures that involve multiple pointers.

How to enable or disable multifinger gestures for Synaptics touchpad?

Enable or Disable MultiFinger Gestures for Synaptics Touchpad in Touchpad Settings 1 Open Settings, and click/tap on the Devices icon. 2 Click/tap on Touchpad on the left side, and click/tap on the Additional settings link under Related settings on the right side. (see screenshot below)

How do I Turn Off gestures on my touchpad?

1 Open Settings, and click/tap on the Devices icon. 2 Click/tap on Touchpad on the left side, select the Swipes and Taps action you want in the drop menus of your available gestures (ex: "Three-finger gestures" and "Four-finger gestures"). (see screenshots below) Selecting Nothing for a gesture will disable it.

Is it touch by finger or disable touch?

I only called it touch by finger in an attempt to help avoid confusion since it doesn't affect the touchpad or stylus pen. I was worried that stating disable touch might get taken as all forms of touch.

How do I enable the two-finger scrolling on the touchpad?

1 Open Settings, and click/tap on the Devices icon. 1 Open Settings, and click/tap on the Devices icon. The Two-Finger scrolling feature allows you to scroll vertically or horizontally from anywhere on the TouchPad surface.


2 Answers

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.

like image 126
deadfish Avatar answered Sep 28 '22 06:09

deadfish


Yes I also faced this issue once and I found solution that android:splitMotionEvents="false" this will work only to direct children of a layout.

Example:

Like if you create two layout A and B and In A you have two buttons b1,b2 In B you have two buttons b3,b4

both A and B are in Parent Layout So first you have to clear that these buttons are not direct children of Parent Layout

In Parent Layout only have two children A and B

Than if you add android:splitMotionEvents="false" to Parent Layout then multi touch will not work on Layout A and Layout B but it will work on every button b1,b2,b3,b4 because these are not direct children of Parent Layout

So , If you want that multi touch will not work on these buttons also Than you have to add android:splitMotionEvents="false" this to every layout separately

There are some cases :

1).If you only add android:splitMotionEvents="false" on Layout A than you can not touch button b1 and button b2 at same time but you can touch button b1 or b2 and button b3 or b4 at same time.

2). just opposite of case 1.

3). But if you add android:splitMotionEvents="false" on both layouts than you can not touch any two buttons on your screen at same time.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:splitMotionEvents="false" >  <LinearLayout     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:splitMotionEvents="false" >      <Button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="b1" />      <Button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="b2" /> </LinearLayout>  <LinearLayout     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:orientation="horizontal"     android:splitMotionEvents="false" >      <Button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="b3" />      <Button         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="b4" /> </LinearLayout> 

I think it might helpful for you.

like image 25
sachin pareek Avatar answered Sep 28 '22 06:09

sachin pareek