Android:更新 ImageView 时保持缩放
我创建了一个简单的应用程序,它将每两秒从网站下载一张 .jpg
图像并将其显示在 ImageView
中。
我向 ImageView 添加了缩放功能,但每次图像更新时,imageview 都会恢复到原始大小。我想确保通过增加缩放,图像的下一次更新,ImageView
保持我设置的尺寸。
你能帮我吗?
感谢大家。
I created a simple application that will download a .jpg
image every two seconds from a website and displays it in an ImageView
.
I added to the ImageView
the zoom functionality, but each time the image is updated the imageview back to original size. I would like to make sure that by increasing the zoom, the next update of the image, the ImageView
maintained the dimensions that I set.
Can you please help me?
Thanks to all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要计算图像与当前缩放级别的比率。您可以通过获取当前大小并将其除以原始大小来完成此操作。非常琐碎的事情。
然后,当新图像到达时,一旦替换图像,就将图像的尺寸更改为原始值乘以比率。
You need to compute for the ratio of the image and the current zoom level. You can do this by getting the current size and divide it by the original size. Pretty trivial stuff.
Then when the new image arrives, as soon as you replace the image, change the dimension of the image by the original value times ratio.