Android上ProgressBar上的背景动画图片?

Jim*_*Hac 8 animation android progress-bar

当您需要更改ProgressBar的背景图像时,需要采取的适当措施是什么?我的意思是应该使用如下的.gif图像:http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif如果是这样的话,前景色会是过程中栏填充图像文件?有没有办法为酒吧的背景创建动画?我的目标是显示动画,因为该过程不会覆盖整个栏.

Pra*_*tik 14

你需要将所有这些gif帧图像作为个体,然后设置到xml文件中的动画列表中.

这是您的anim_progress.xml文件代码

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false">
    <item android:drawable="@drawable/i1" android:duration="500" />
    <item android:drawable="@drawable/i2" android:duration="500" />
    <item android:drawable="@drawable/i3" android:duration="500" />
    <item android:drawable="@drawable/i4" android:duration="500" />
    <item android:drawable="@drawable/i5" android:duration="500" />
    <item android:drawable="@drawable/i6" android:duration="500" />
    <item android:drawable="@drawable/i7" android:duration="500" />
    <item android:drawable="@drawable/i8" android:duration="500" />
</animation-list>
Run Code Online (Sandbox Code Playgroud)

将更改的持续时间设置为为gif等动画图像提供平滑效果

以下是使用此文件的代码

ImageView iv = new ImageView(this);
iv.setBackgroundResource(R.drawable.anim_progress);
final AnimationDrawable mailAnimation = (AnimationDrawable) iv.getBackground();
iv.post(new Runnable() {
    public void run() {
        if ( mailAnimation != null ) mailAnimation.start();
      }
});
Run Code Online (Sandbox Code Playgroud)

的setContentView(IV);

你可以从这个站点获取gif文件中的所有帧.

http://gif-explode.com/

例如

http://2.bp.blogspot.com/-O7nsXfmgwSc/T6PQ0PVr6-I/AAAAAAAAAQI/-eXkEXj24-s/s1600/02.gif

这个链接只是传递它,你将获得所有的帧图像