我有一个图像视图,宽度设置为400dp,高度设置为300dp。这个图像视图用于列表视图中,在该列表视图中,我从url加载图片。在加载图片时,我显示一个类似于进度条的动画,设置如下:
imageView.setBackgroundResource(R.drawable.progress);
final AnimationDrawable startAnimation = (AnimationDrawable) imageView
.getBackground();
startAnimation.start();
一旦图片加载完成,我将移除此动画,并将已加载的图像设置如下:
imageView.setBackgroundResource(0);
imageView.setImageBitmap(bitmap);
但问题是,动画也使用了指定的宽度和高度,即400dp和300dp,我如何仅减小动画可绘制对象的大小?
我的动画文件:progress.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/anim_black"
android:oneshot="false" >
<item
android:drawable="@drawable/frame_1"
android:duration="100"/>
<item
android:drawable="@drawable/frame_2"
android:duration="100"/>
<item
android:drawable="@drawable/frame_3"
android:duration="100"/>
<item
android:drawable="@drawable/frame_4"
android:duration="100"/>
<item
android:drawable="@drawable/frame_5"
android:duration="100"/>
<item
android:drawable="@drawable/frame_6"
android:duration="100"/>
<item
android:drawable="@drawable/frame_7"
android:duration="100"/>
<item
android:drawable="@drawable/frame_8"
android:duration="100"/>
<item
android:drawable="@drawable/frame_9"
android:duration="100"/>
<item
android:drawable="@drawable/frame_10"
android:duration="100"/>
<item
android:drawable="@drawable/frame_11"
android:duration="100"/>
<item
android:drawable="@drawable/frame_12"
android:duration="100"/>
</animation-list>
帧1、帧2……帧12是我通过分割GIF图像获得的PNG文件。