检测您的手指在 Android 中滑过的视图 [英] Detect which view your finger is sliding over in Android

查看:23
本文介绍了检测您的手指在 Android 中滑过的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然类似 问题 过去曾被问过,但似乎并没有真正得到回答,这可能是由于对所问的内容感到困惑.

While similar questions have been asked in the past they don't seem to really have been answered which might be due to confusion as to what's being asked.

简而言之,当您的手指在屏幕上滑动时,我想检测正在进入的视图.最好的例子就是任何安卓手机上的软键盘.当您按任意键时,它会显示一个弹出窗口,告诉您手指下的字母是什么.如果您现在以一个手势在键盘上移动手指,当您在字母表中的各种字母上移动时,会弹出各种字母.

Put simply, I'd like to detect which view is being entered as your finger slides over the screen. The best example of this in action is the soft keyboard on any android phone. When you press any key it shows up as a popup to tell you what letter is under your finger. If you now move your finger over the keyboard in a single gesture the various letters pop up as you move over the various letters of the alphabet.

什么监听器用于这种类型的行为.我试过 OnTouchListeners 但它们似乎只有当你触摸"按钮而不是手指经过"它们时才会出现

What listeners are used for this type of behaviour. I've tried OnTouchListeners but they seem to be only when you 'touch' the button as opposed to 'finger past' them

Button button = (Button)findViewById(R.id.button);
button.setOnClickListener(new OnClickListener() {
  @Override
  public void onClick(View v) {doStuff();}
});

button.setOnTouchListener(new OnTouchListener() {
  @Override
  public boolean onTouch(View v, MotionEvent event) {
      doStuff();
      return false;
  }
});

OnFocusChangeListener 也没有帮助.

推荐答案

简单的答案是你不能 - 在无障碍模式下不像 iPhone.

The simple answer is you can't - not like the iPhone when in accessibility mode.

直到冰淇淋三明治.它现在具有类似 iPhone 的功能,无需抬起手指即可识别手指下方的元素.

Until Ice Cream Sandwich that is. It now has the iPhone-like capability of being able to identify elements under your finger without having to lift it.

这篇关于检测您的手指在 Android 中滑过的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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