S.M_Emamian
S.M_Emamian

Reputation: 17393

Animating an imageview from center layout to top right

I have an image view that it set top and right of layout.

<RelativeLayout...

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/image" />
...

now, I would like to make an animation from center layout to default position(top and right layout).

like :

enter image description here

Upvotes: 0

Views: 976

Answers (2)

kapil
kapil

Reputation: 1

50% is center of animated view.

50%p is center of parent

<scale
android:fromXScale="1.0"
android:toXScale="1.2"
android:fromYScale="1.0"
android:toYScale="1.2"
android:pivotX="50%p"
android:pivotY="50%p"
android:duration="175"/>

Upvotes: 0

Parth Kapoor
Parth Kapoor

Reputation: 1504

This animation xml may help if you have your image placed centrally.

<?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:fromXDelta="0%p" android:toXDelta="100%p" 
    android:duration="500"/>
</set>

Upvotes: 1

Related Questions