相关疑难解决方法(0)

如何在onCreate之后立即启动动画?

我正在关注http://developer.android.com/guide/topics/graphics/view-animation.html#frame-animation并进行细微更改.我决定制作动画循环并希望它从一开始就开始.

我的动画是drawable/listening.xml:

<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
    android:drawable="@drawable/l_01"
    android:duration="200" />
<item
    android:drawable="@drawable/l_02"
    android:duration="200" />
<item
    android:drawable="@drawable/l_03"
    android:duration="200" />
</animation-list>
Run Code Online (Sandbox Code Playgroud)

和我的初始代码:

 @Override public void onWindowFocusChanged(boolean hasFocus)  { 
      super.onWindowFocusChanged(hasFocus); 
      animImg = (ImageView)findViewById(R.id.listen_anim);
      animImg.setBackgroundResource(R.drawable.listening);
      anim = (AnimationDrawable) animImg.getBackground(); 
      anim.start();
 };
Run Code Online (Sandbox Code Playgroud)

我看到的只是第一帧而没有其他图像.

android android-animation

15
推荐指数
4
解决办法
3万
查看次数

标签 统计

android ×1

android-animation ×1