我想要将屏幕中间的两幅图像制作成彼此相反的动画。像下面的图片。如何将两个图像视图从中心动画到彼此相反?
无论我迄今所做的是正确的,现在我是从左至右,反之亦然能够有生只有一个形象,但现在我想从中间动画。
这里是我的代码:
b1 = (Button) findViewById(R.id.button1);
logo = (ImageView) findViewById(R.id.imageView1);
Display display = getWindowManager().getDefaultDisplay();
width = display.getWidth();
final Animation posX = new TranslateAnimation(0, width - 50, 0, 0);
posX.setDuration(1500);
posX.setFillAfter(true);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
logo.startAnimation(posX);
logo.setVisibility(View.VISIBLE);
}
});
编辑:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="@drawable/set_user_profile_back"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:contentDescription="@string/hello_world"
android:src="@drawable/prev_btn" />
<ImageView
android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:contentDescription="@string/hello_world"
android:src="@drawable/next_btn" />
</RelativeLayout>
感谢
你必须使用对象的动画,它可以在同一时间动画多个项目。 – 2013-04-24 12:25:53
给每个图像一个动画侦听器,每个图像都有特定的转换值 – 2013-04-24 12:27:57
@AndroidDeveloper如果您可以提供任何相关链接 – juned 2013-04-24 12:32:00