我将此代码写入我的图像animate:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
ImageView img=(ImageView) findViewById(R.id.backImage);
ImageView img2=(ImageView) findViewById(R.id.upImage);
animBounce=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
animBounce.setAnimationListener(this);
img.setVisibility(View.VISIBLE);
img.setAnimation(animBounce);
img2.setAnimation(animBounce);
}
我在xml文件中有两个imageView,imageView1名称backImage和xml文件中的imageView2名称upImage。
我想img开始动画,并在1000ms img2开始动画,但在这个我的代码img和img2同时开始。
如何解决这个问题?
答案 0 :(得分:0)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
ImageView img=(ImageView) findViewById(R.id.backImage);
ImageView img2=(ImageView) findViewById(R.id.upImage);
animBounce=AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
animBounce.setAnimationListener(this);
img.setVisibility(View.VISIBLE);
img.setAnimation(animBounce);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
img2.setAnimation(animBounce);
}
}, 1000);
}
将其添加到onCreate
方法的末尾。我希望它有所帮助。