Android - 闪烁 ImageView 进度对话框
我想为我的应用程序制作一个 ProgressDialog,在后台加载资源时使用闪烁图像。我在 StackOverflow 上查看了一些有关创建不确定动画(大部分是圆形)的问题。但是,我似乎找不到任何有关如何使用静态图像制作闪烁进度对话框的信息。我意识到我可以在 XML 中定义动画,但如何控制图像的时间,更重要的是,如何添加淡入和淡出?
I want to make a ProgressDialog for my app that used flashes an image while resources are loaded in the background. I've looked at a number of questions on StackOverflow that deal with creating indeterminate animation, mostly circular. However, I can't seem to find any information on how to make a flashing progress dialog with a static image. I realize that I can define the animation in XML but how do I control the timing of the image and more importantly, how can I add fade in and fade out ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您可能已经发现的,您必须创建一个自定义对话框:
http://developer.android.com/guide/topics/ui/dialogs.html
在此对话框中您将看到您的图像。您还需要一个与此类似(但不完全相同)的动画文件:
您可以更改持续时间以及设置“repeatCount”之类的内容。
然后在您的代码中,您将启用图像上的动画,如下所示:
因此,您可以使用“duration”和“repeatCount”控制时间。然后你可以通过设置'toAlpha'和'fromAlpha'来控制淡入和淡出。
当然,这是伪代码,并不完全是您需要做的...但希望它足以让您开始...
As you've probably already found out you'll have to create a custom dialog:
http://developer.android.com/guide/topics/ui/dialogs.html
In this dialog you will have your image. You will also need an animation file similar (but not exact) to this:
You can change the duration as well set something like a 'repeatCount'.
Then in your code you will enable the animation on the image as such:
So, you can control the timing with 'duration' and 'repeatCount'. Then you can control the fading in and out by setting the 'toAlpha' and 'fromAlpha'.
Of course, this is pseudocode and not exactly what you need to do...but hopefully its enough to get you started...