我有我已經設置爲400dp(寬度)和300dp(高度)的圖像圖。此圖像視圖用於我從url加載圖像的列表視圖。期間的圖像的加載,我示出陸侃酒吧等動畫被設置是這樣的:的Android - imageview.setBackgroundResource發出
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是PNG文件其中我被分割GIF圖像。
你是否嘗試設置動畫繪製爲setImageResource(而不是setBackgroundResource) – MatrixDev 2013-04-25 12:47:30