如何制作一个打印触摸点并绘制它们的Android应用程序?
我想做一个小应用程序。您将触摸屏幕并绘制一些内容,它会列出您经过的点,并为每第五个点绘制绿色的 3x3 小矩形。我使用 onTouchEvent 使用 TextView 列出点并将其发送到 setContentView。但是,我在绘画方面遇到了问题。我检查了绘图(onDraw)的示例,但我无法让它同时适用于打印点和绘制绿点。任何帮助都会很棒,谢谢。
I want to make a small app. You will touch the screen and draw something and it will list points you pass and draw small green 3x3 rectangles for each fifth point. I use onTouchEvent for listing points using TextView and send it to setContentView. However, I have problem in drawing. I checked examples for drawing (onDraw) but I am not able to get it working for both printing point plus drawing green dots. Any help would be great, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是在
SurfaceView
上绘图的快速示例。Here you are, a quick sample of drawing on
SurfaceView
.目前尚不完全清楚您要做什么,但请查看 this< /a> 它应该让你朝着正确的方向开始。基本上扩展一个视图并重写
onDraw(Canvas)
来绘制矩形并重写onTouchEvent(MotionEvent)
来从屏幕上抓取触摸点。It's not entirely clear what you're trying to do, but have a look at this It should get you started in the right direction. Basically extend a View and override the
onDraw(Canvas)
to draw the Rectangles and override theonTouchEvent(MotionEvent)
to grab the touch points from the screen.