在悬停时更改图像而无需触摸android中的屏幕 [英] Change an image on hover without touching the screen in android

查看:67
本文介绍了在悬停时更改图像而无需触摸android中的屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常有创造力的要求-我不确定这是否可行-但如果可以的话,肯定会为我的应用增添趣味.

I have a very creative requirement - I am not sure if this is feasible - but it would certainly spice up my app if it could .

前提:在Android手机上,如果手盖了屏幕(没有触摸,只是靠近屏幕),或者 在通话过程中将手机放在耳朵上方,或者将手机锁定或 基本上是黑掉了.所以必须有一些技术来认识到 我的手在屏幕附近.

Premise: On Android phones, if the screen is covered by hand(not touching, just close to the screen) or if the phone is placed over the ear during a call the phone locks or basically it blacks out. So there must be some tech to recognize that my hand is near the screen.

问题:我的应用中有一张图片.如果 用户无需触摸屏幕即可指向图片,就像 扩展前提,我必须能够知道用户是 指向图像并更改图像.这可能吗?

Problem: I have an image in my app. If the user points to the image without touching the screen, just as an extension to the premise, I must be able to know that the user is pointing to the image and change the image. Is this possible ?

更新:用法示例:

说我想构建一个有趣的应用,触摸后图像会导致其他问题 地方.例如-我有两扇门,一扇通往汽车,一扇通往狮子. 现在,当用户即将触摸门1时-门应显示 一条消息说你确定,然后实际触摸它会带你 到另一个地方.有点样的例子,但我希望你能理解 点

Say I want to build a fun app, on touch the image leads to some other place. For example - I have two doors one to a car and one to a lion. Now just when the user is about to touch door 1 - the door should show a message saying are you sure, and then actually touching it takes you to another place. Kinda rudimentary example, but I hope you get the point

推荐答案

您正在谈论的功能是接近传感器.请参见 Sensor

The feature you are talking about is the proximity sensor. See Sensor and SensorEvent.values for Sensor.TYPE_PROXIMITY.

您可以得到手与屏幕之间的距离,但您实际上无法确定手在XY坐标系中的哪个位置.因此,您将无法弄清楚用户是指向车门"还是指向狮子门".

You could get the distance of the hand from the screen, but you won't really be sure where in the XY co-ordinate system the hand is. So you won't be able to figure out whether the user is pointing to the "car door" or to the "lion door".

这篇关于在悬停时更改图像而无需触摸android中的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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