android 需要建议来开始使用手势进行开发
我有一个 canvas.DrawText。
我想使用手势来动态更改文本颜色和字体。使用弹出视图类这一切都可以很好地工作。但我想让这更直接也许使用 Fling 滚动。
有数百万种颜色,通过在屏幕上滑动手指,我想我可以增加/减少 colorInteger 并将其发送到 paint.setColor(colorInteger );
在绘制之前。我一整天都尝试使用各种方法。
我有 public boolean onTouchEvent(MotionEvent event) {
我知道我必须捕获 MotionEvent.ACTION_DOWN
中的 x/y
想要使用屏幕左边缘进行颜色更改和屏幕右边缘用于字体更改。我有 21 种 ttf 字体。
问题是,我看到有 OnGestureListener onscroll
实现,但这会禁用我的 onTouchEvent
对吧?我那里正在进行很多活动。
public boolean onTouchEvent(MotionEvent event) {
有什么想法吗?
I have a canvas.DrawText.
I want to use gestures to dynamically change the text color and font. This is all working nice using a popup view class. But I want to make this more direct maybe using Fling scroll.
There are millions of colors and by sliding finger on the screen I thought I could increase/decrease the colorInteger and send it to paint.setColor(colorInteger );
before I draw. I have tried all day using various methods.
I have public boolean onTouchEvent(MotionEvent event) {
I know I must catch the x/y in MotionEvent.ACTION_DOWN
Wanted to use the screen left edge for color change and screen right for Font change. I have 21 ttf fonts.
The thing is, I see there is the OnGestureListener onscroll
implementation but that will disable my onTouchEvent
right? I have lots of movement going on in there.
public boolean onTouchEvent(MotionEvent event) {
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
GestureDetector
。实现一个GestureDetector.OnGestureListener
并在那里捕获手势。为 GestureDetector 提供如下触摸事件:
在
GestureDetector.OnGestureListener
的onDown
中,如果要处理此手势,则必须返回true
。例如,然后用户将手指放在指定区域返回true
,否则返回false
。如果此处返回 false,则不会检测到从此事件开始的复杂序列(例如 fling 或scroll)。You can use
GestureDetector
. Implement aGestureDetector.OnGestureListener
and catch gestures there.Provide GestureDetector with touch events like this:
In
GestureDetector.OnGestureListener
'sonDown
you must returntrue
if you want to process this gesture. E.g. then the user puts his finger donw in a specified area returntrue
, andfalse
otherwise. Iffalse
is returned here, complicated sequences (like fling or scroll) started with this event will not be detected.