动画(瓶子旋转)后如何在屏幕上显示某些文本?我知道您需要分配一个听众,但不需要了解现实中的一切。这是动画代码:
public class ActivityGame extends AppCompatActivity {
public static final Random sRandom = new Random();
private ImageView mBottleImageView;
private int lastAngle = -1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game_activity);
mBottleImageView = (ImageView) findViewById(R.id.imageview_bottle);
mBottleImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
spinBottle();
}
});
}
private void spinBottle() {
int angle = sRandom.nextInt(3500-200)+700;
// Центр вращения
float pivotX = mBottleImageView.getWidth() / 2;
float pivotY = mBottleImageView.getHeight() / 2;
final Animation animation = new RotateAnimation(lastAngle == -1 ? 0 : lastAngle, angle, pivotX, pivotY);
lastAngle = angle;
animation.setDuration(3000);
animation.setFillAfter(true);
mBottleImageView.startAnimation(animation);
}
}
你说你需要一个听众是正确的: