我正在尝试在 Android 上同时进行多个翻译。
我在布局上有 2 个或更多按钮(大小都相同),当我按下一个按钮时,我希望其他按钮移出屏幕。
我已经做了一个测试应用程序来尝试实现这种行为。
在它上面我设置了一个点击一个按钮来测试的监听器,比如:
button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View view) {
        Button toMove = (Button) findViewById(R.id.button_test2);
        Button toMove2 = (Button) findViewById(R.id.button_test3);
        AnimationSet set = new AnimationSet(true);
        TranslateAnimation anim = new TranslateAnimation(0, -toMove
          .getWidth(), 0, 0);
        anim.setFillAfter(true);
        anim.setDuration(1000);
        toMove.setAnimation(anim);
        toMove2.setAnimation(anim);
        set.addAnimation(anim);
        set.startNow();
    }
风景:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button android:id="@+id/button_test" android:layout_width="200px"
        android:layout_height="50px" android:text="@string/hello" />
    <Button android:id="@+id/button_test2" android:layout_width="200px"
        android:layout_height="50px" android:text="@string/hello"/>
    <Button android:id="@+id/button_test3" android:layout_width="200px"
        android:layout_height="50px" android:text="@string/hello"/>
</LinearLayout>
问题是两个按钮开始动画,一个接一个。我已经读到这是由于getDelayForView()每个返回不同的延迟。有没有办法同时移动 2 个或更多按钮?
谷歌不是很有帮助:-\