1

I have one image and two imageview in relativelayout with different position and one of them is have width and height value.(below layout and screenshot ). I want to use animation that big image move and scale to on corner small image. Have can i do this animate?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_margin="50dp"
        android:src="@drawable/image1" />

     <ImageView
        android:id="@+id/imageView2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="5dp"
        android:layout_marginBottom="5dp"        
        android:src="@drawable/image1" />

</RelativeLayout>

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
isyap
  • 121
  • 1
  • 2
  • 6

1 Answers1

0

I don't know if it is still relevant, but this answer to a similar question might help you.

The only thing you need to do is to set the scale value according to your case e.g. from

new ScaleAnimation(1f, 2f, 1f, 2f, ScaleAnimation.RELATIVE_TO_PARENT, .5f, ScaleAnimation.RELATIVE_TO_PARENT, .5f);

to

new ScaleAnimation(2f, 1f, 2f, 1f, ScaleAnimation.RELATIVE_TO_SELF, .5f, ScaleAnimation.RELATIVE_TO_SELF, .5f);

to scale down the image for example.

The first four parameters mean:

  1. scaleFrom (x Axis)
  2. scaleTo (x-Axis)
  3. scaleFrom (y-Axis)
  4. scaleTo (y-Axis)

The rest of the paremeters indicate that the image should be zoomed around its center.

Hope this helps!

Community
  • 1
  • 1
KitKat
  • 11
  • 2