Android で複数の翻訳を同時に実行しようとしています。
レイアウト上に 2 つ以上のボタン (すべて同じサイズ) があり、1 つを押すと、他のボタンが画面の外に出ます。
この動作を実装するためにテストアプリを作成しました。
その上で、テストするボタンのクリックでリスナーを設定しました。
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>
問題は、2 つのボタンが少しずつ交互にアニメーションを開始することです。getDelayForView()
それは、それぞれの異なる遅延を返すためであると読みました。2つ以上のボタンを同時に動かす方法はありますか?
Google はあまり役に立ちませんでした:-\