Is it possible to combine these 2 animations below? It works but it seems weird to have to call them separately ( 2 calls to start() )
ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
rocketImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
rocketAnimation.start();
rocketImage.animate().x(100).y(100).withLayer().setDuration(500).start();
}
});
See AnimatorSet and use the function
playTogether. However, as you mentioned in your comments,AnimationDrawableis not compatible withAnimatorSet. In this case, to ensure both animations start together, you can write it like this});