有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Android动画中的按钮

我通过动画移动我的按钮,按钮在视觉上移动,但当我在新位置按下按钮时,我在那里找不到它

final Animation animation1 = new TranslateAnimation(0,0,0,100);
animation1.setDuration(5000);
animation1.setFillAfter(true);
alphabet.startAnimation(animation1);
humanbody.startAnimation(animation1);
poem.startAnimation(animation1);
game.startAnimation(animation1);

当我按下字母表按钮时,它带我进入人体活动,我按下字母表按钮顶部的某个地方,它带我进入字母表活动


共 (1) 个答案

  1. # 1 楼答案

    我仍然是这方面的初学者,但我认为使用animation类只会为view's可绘制状态设置动画,而不是它的绑定/触摸区域。 尝试使用以下方法:

    int t = 5000;
    int y = 100;
    alphabet.animate().setDuration(t).translateY(y).start();
    humanbody.animate().setDuration(t).translateY(y).start();
    poem.animate().setDuration(t).translateY(y).start();
    game.animate().setDuration(t).translateY(y).start();