Android 如何以自定义速度移动ImageView?

Android 如何以自定义速度移动ImageView?,android,animation,Android,Animation,我想在活动开始时创建简单的移动对象,但我找不到解决方案 假设我有一个ImageView: <ImageView android:id="@+id/image_view" android:layout_width="50dp" android:layout_height="50dp" android:src="@drawable/image"/> 任何帮助都将不胜感激。您必须使用动画: ImageView img = (ImageView)findVi

我想在活动开始时创建简单的移动对象,但我找不到解决方案

假设我有一个ImageView:

<ImageView
    android:id="@+id/image_view"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:src="@drawable/image"/>

任何帮助都将不胜感激。

您必须使用动画:

ImageView img = (ImageView)findViewById(R.id.img);

    TranslateAnimation ta = new TranslateAnimation(0,0,300,200);
    ta.setDuration(5000);
    img.startAnimation(ta);

您必须使用动画:

ImageView img = (ImageView)findViewById(R.id.img);

    TranslateAnimation ta = new TranslateAnimation(0,0,300,200);
    ta.setDuration(5000);
    img.startAnimation(ta);