我试图使帧动画停留在图像视图的中心,在下载图像之前动画正在其中播放。基本上它是一个加载旋转器的动画。这是我在xml文件中的图像视图。
<TableRow
android:gravity="center" >
<ImageView
android:id="@+id/imageViewUrl1"
android:layout_width="0dp"
android:layout_height="94dp"
android:layout_gravity="center"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:gravity="center"
android:onClick="OnClickThumbnail"
android:paddingTop="10dp"
android:scaleType="fitCenter"
android:textColor="@android:color/white"
android:src="@drawable/frameblack" />这是我的框架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/framezero" android:duration="60" />
<item android:drawable="@drawable/frameone" android:duration="60" />
<item android:drawable="@drawable/frametwo" android:duration="60" />
<item android:drawable="@drawable/framethree" android:duration="60" />
<item android:drawable="@drawable/framefour" android:duration="60" />
<item android:drawable="@drawable/framefive" android:duration="60" />
<item android:drawable="@drawable/framesix" android:duration="60" />
<item android:drawable="@drawable/frameseven" android:duration="60" />
<item android:drawable="@drawable/frameeight" android:duration="60" />
<item android:drawable="@drawable/framenine" android:duration="60" />
<item android:drawable="@drawable/frameten" android:duration="60" />
</animation-list>下面是我用来启动动画的代码
final ImageView imageView = (ImageView) findViewById(R.id.imageViewUrl1);
AnimationDrawable yourAnimation;
imageView.setBackgroundResource(R.drawable.loadinganim);
yourAnimation = (AnimationDrawable) imageView.getBackground();
yourAnimation.start();问题是动画扩展了图像视图的整个宽度和高度。图像视图设置为fitCenter。我怎么才能避免这种情况呢?
发布于 2014-02-02 07:21:31
我有同样的问题,问题是因为动画使用背景
解决办法是:
https://stackoverflow.com/questions/13309236
复制相似问题