7
我正在尝试在Android上同时做几个翻译。同时在Android上翻译
我有两个或更多的按钮布局(所有相同的大小),当我按下一个我希望其他人移出屏幕。
我已经做了一个测试应用程序来尝试实现这种行为。
就可以了,我设置一个按钮的点击监听器来测试,这样的:
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()
返回不同的延迟。有什么办法可以同时移动两个或多个按钮吗?
谷歌是不是非常有帮助: - \
这行不通形成我吗? – 2013-12-30 12:33:22