1

I have an Imageview in a RelativeLayout. It should start from the centre of the screen (parent) and than goes to a specific point. Actual i work with xml. Any Solutions?

My Animation XML-

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

  <translate
        android:fromYDelta="0%p"
        android:fromXDelta="0%p"
        android:toYDelta="0%"
        android:toXDelta="0%"
        android:duration="1000"
        android:pivotX="0%p"
        android:pivotY="0%p"/>

  <scale xmlns:android="http://schemas.android.com/apk/res/android"
      android:fromXScale="432px"
      android:toXScale="100%"
      android:fromYScale="450px"
      android:toYScale="100%"
      android:duration="1000"
      android:pivotX="0%p"
      android:pivotY="0%p" />
</set>

I've tried it in fromYDelta and fromXDelta with 100%p, 50%p, 0%p, 100, 50, 0, 100%, 50% and 0%. Nothing works! Now im confused! Thanks for your time and help

Edit:

A picture to explain what the Animation should do

Lerinir Hurin
  • 11
  • 1
  • 5

1 Answers1

0

Add this in anim folder:

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="50%p" android:fromYDelta="50%p" 
    android:toXDelta="50%p" android:toYDelta="0%p" 
    android:duration="1000" 
    android:fillAfter="true" />

Implement this in code like :

translateAnim= AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.translate_anim);
imageView.startAnimation(translateAnim);

This will move image from centre to top.

Aj 27
  • 2,316
  • 21
  • 29