如何在Android手机上正确显示加载图像

发布于 2024-10-09 03:04:16 字数 99 浏览 16 评论 0原文

我一直在尝试使用资源中的 .gif 文件,但加载时没有任何动静。我在执行异步任务时将其用作加载图像。我以前使用进度对话框,但现在我想自己显示图像而不使用对话框。如何才能正确显示该图像?

I have been trying to use a .gif file from my resources, but I get no movement when it loads. I am using it as a loading image while I am doing an asynchronous task. I was previously using a progress dialog but now I would like to display the image myself and not use a dialog. How can I get this image to display correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

梦萦几度 2024-10-16 03:04:16

尝试使用AnimationDrawable:
http://developer.android.com/reference/android/graphics/drawable /AnimationDrawable.html

基本上,您应该将 gif 中的每个帧拆分为单独的文件 - 例如 .png 文件(假设它具有透明度),并在 中指定这些文件; 代替。您还可以控制每帧的持续时间。

请参阅链接以获取代码示例

Try using AnimationDrawable:
http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

Basically, you should split each of the frames in your gif into separate files - such as .png file (say if it had transparency) and specify these files in the <animation-list> instead. You can also control the duration of each frame.

See the link for code example

冷了相思 2024-10-16 03:04:16

如果您执意要使用 gif 图像,您可以使用 WebView 而不是 ImageView。然后制作一个显示 gif 图像的 html 文档。当您在 WebView 中显示它时,它将为您呈现动画。

If you are deadset on using a gif image you can just use a WebView instead of an ImageView. Then make an html doc that displays your gif image. When you show it in the WebView it will be animated for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文