我正在寻找一个示例代码,我的xml很好,我想在活动开始时立即启动动画,而不是按任何东西
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class AnimationActivity extends Activity
{
ImageView genie;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
genie = (ImageView)findViewById(R.id.genieout);
genie.setBackgroundResource(R.drawable.genieani);
genie.post(new Runnable() {
@Override
public void run() {
AnimationDrawable genieout =
(AnimationDrawable) genie.getBackground();
genieout.start();
}
});
}
答案 0 :(得分:1)
public void onStart() {
super.onStart();
myImageView.startAnimation( myAnimation );
}
答案 1 :(得分:0)
看看NineOldAndroids。是一个非常好的库,可以将HoneyComb +动画反向回到android 1.0。
很确定你会在这里的库示例源代码中找到你需要的东西
https://github.com/JakeWharton/NineOldAndroids/tree/master/sample