ImageView 在平板电脑中缓慢更改图像
我正在为Android编写一个键盘替换应用程序,并根据用户的触摸,在指定的ImageView中呈现不同的图像。我遇到了两件事的问题:
1) 使用平板电脑,我可以更快地移动手指,因此我使用的 onTouch
方法正在丢失触摸事件。例如,在快速循环中,我的触摸模式如下所示:(
x: 590.0 y: 178.0
x: 488.0 y: 172.0
x: 233.0 y: 416.0
x: 394.0 y: 451.0
x: 575.0 y: 199.0
x: 450.0 y: 170.0
x: 341.0 y: 193.0
使用 Logcat 和 event.getX()、event.getY())
是否有更好的方法使用平板电脑跟踪事件以获取更多事件?
2) 图像视图中变化的图像呈现速度比手机应用程序慢。有没有办法解决这个问题,或者这是平板电脑的限制?我通过以下方式更改图像视图:
myImageView.setImageDrawable(image);
有什么想法吗?
I am writing a keyboard replacement app for Android, and based on the user's touch, a different image is rendered in a specified ImageView. I am running into an issue with two things:
1) With the tablet, I can move my finger quicker, so the onTouch
method I am using is losing touch events. For instance, in a quick circle, my touch pattern looks like this:
x: 590.0 y: 178.0
x: 488.0 y: 172.0
x: 233.0 y: 416.0
x: 394.0 y: 451.0
x: 575.0 y: 199.0
x: 450.0 y: 170.0
x: 341.0 y: 193.0
(using Logcat and event.getX(), event.getY())
Is there a better way track events with a tablet to pick up more events?
2) The changing image in the imageview renders slower than in the phone app. Is there a way to fix this, or is it a limitation of the tablet? I change the imageview by:
myImageView.setImageDrawable(image);
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试自定义视图和 onTouch 事件。您必须将所有按钮状态预加载为位图。
请参阅此示例: 使位图的某些区域在触摸时透明
You could try a custom view and onTouch event. You would have to pre-load all your buttons states as bitmaps.
See this example: Make certain area of bitmap transparent on touch
我通过 BitmapFactory 预解码获得了更好的性能,它应该看起来像这样(未经测试):
I get much better performance pre-decoding it via
BitmapFactory
, which should look something like this (untested):