Android 在安卓系统中,动画期间图像不会移动到屏幕底部

Android 在安卓系统中,动画期间图像不会移动到屏幕底部,android,Android,我是android新手。 我正在做一个项目,我想把图像从屏幕的顶部移动到底部。 我已经为此编写了代码,但我的图像会移动到屏幕中间,并返回到屏幕顶部,而不会到达底部 这是我的MainActivity.java文件 setContentView(R.layout.activity_eg_main); ImageView image = (ImageView) findViewById(R.id.image1); image.setImageResource(R.drawab

我是android新手。 我正在做一个项目,我想把图像从屏幕的顶部移动到底部。 我已经为此编写了代码,但我的图像会移动到屏幕中间,并返回到屏幕顶部,而不会到达底部

这是我的MainActivity.java文件

    setContentView(R.layout.activity_eg_main);

    ImageView image = (ImageView) findViewById(R.id.image1);
    image.setImageResource(R.drawable.ic_launcher);
    Animation animation = AnimationUtils.loadAnimation(this, R.anim.testing);
    image.startAnimation(animation);
这是我的res/layout/activity\u eg\u main.xml

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:paddingBottom="@dimen/activity_vertical_margin"
   android:paddingLeft="@dimen/activity_horizontal_margin"
   android:paddingRight="@dimen/activity_horizontal_margin"
   android:paddingTop="@dimen/activity_vertical_margin"
   tools:context="com.example.example.EgMainActivity" >


    <ImageView
        android:id="@+id/image1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/hehe"
        android:layout_alignParentTop="true" 
        />

   </RelativeLayout>

这是我的res/anim/testing.xml文件

<?xml version="1.0" encoding="utf-8"?>

  <set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
             android:fromYDelta="0"
             android:toYDelta="100"
             android:duration="1000">
    </translate>

 </set>

请尽快建议更正。。。 提前感谢….

<translate
         android:fromYDelta="0%"
         android:toYDelta="100%"
         android:duration="1000">
</translate>
不管怎样,我明白了。。。 将android:toYDelta更改为“0%p”,将android:toYDelta更改为“100%p”成功了

<?xml version="1.0" encoding="utf-8"?>
  <set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
      android:fromYDelta="0%p"
      android:toYDelta="100%p"
      android:duration="5000"
     />

 </set>


感谢您的回复…….slide\u up.xml工作正常……但不是slide\u down\u xml。我如何确保它适用于不同的屏幕尺寸……感谢您的回复……slide\u up.xml可以正常工作……但slide\u down\u xml不能。如何确保它适用于不同的屏幕尺寸。。。。如果我使用%的话,动画就不会向下延伸……我想听到一个很好的答案,它适用于不同长度的屏幕,并使用%的android:fromXXXX属性。。。。请尽快发布答案。。。
<set xmlns:android="http://schemas.android.com/apk/res/android">  
    <translate android:fromXDelta="0" android:fromYDelta="1000" android:duration="1500"/>
</set>
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
ImageView img = (ImageView) findViewById(R.id.imgv);
img.startAnimation(slideUp);
<?xml version="1.0" encoding="utf-8"?>
  <set xmlns:android="http://schemas.android.com/apk/res/android" >
    <translate
      android:fromYDelta="0%p"
      android:toYDelta="100%p"
      android:duration="5000"
     />

 </set>