ImageView 在平板电脑中缓慢更改图像

发布于 2024-12-22 10:29:39 字数 566 浏览 2 评论 0原文

我正在为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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃酥萝莉 2024-12-29 10:29:39

您可以尝试自定义视图和 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

落叶缤纷 2024-12-29 10:29:39

我通过 BitmapFactory 预解码获得了更好的性能,它应该看起来像这样(未经测试):

myBitmap=BitmapFactory.decodeResource(myImageView.getContext().getResources(),R.res.drawable.my_image);
//later
myImageView.setImageBitmap(myBitmap);

I get much better performance pre-decoding it via BitmapFactory, which should look something like this (untested):

myBitmap=BitmapFactory.decodeResource(myImageView.getContext().getResources(),R.res.drawable.my_image);
//later
myImageView.setImageBitmap(myBitmap);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文