禁用多手指触摸我的应用程序 [英] Disable multi finger touch in my app

查看:173
本文介绍了禁用多手指触摸我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用一个活动举办几个片段。一个片段上示出各片段的电话屏幕的屏幕视图每次由多个图像图标。

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.

目前,用户可以preSS的两个图标的同时用两个手指(上一个图标每个fingure preSS)。 我想在我的应用程序禁用此多点触控功能允许的只有一个图标preSS生效的时间

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.

我尝试以下方式:

方法1:我的应用程序的主题,我说:

Way 1: in my app theme, I added:

<item name="android:windowEnableSplitTouch">false</item>

2的方式:在Android的清单XML,我说:

Way 2: In Android Manifest xml, I added:

<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="false" />

路3:在我的活动:

@Override
public boolean onTouchEvent(MotionEvent event) {

    if(event.getPointerCount() > 1) {
        System.out.println("Multitouch detected!");
        return true;
    }
    else
       return super.onTouchEvent(event);
    }

不幸的是,没有我的解决方案的工作。因此,如何,我可以在我的应用程序禁用多点触控功能

推荐答案

有关情况:你有多个按钮,你想使选择只有一个按钮。 在父(不是root,只要父母子女)的按钮,在它的XML PARAMS添加

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

安卓splitMotionEvents =假

android:splitMotionEvents="false"

就是这样。 例如:

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

顺便说一句。当你有2 LinearLayout中,每个布局3个按钮,您应该设置这个splitMotionEvents在这两种布局的以及在父母那2 linearLayouts 。否则,你就可以点击每个版面只有一个按钮(总和= 2的话)。我希望你能得到它。 :)

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.

这篇关于禁用多手指触摸我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆