2

I'm new to Android developing. I want some animations when clicking on the card and it will move around the screen and stay at its new position forever (its interactive area should change too).

At first the card is located at the center-bottom of the screen (XDelta= 50% YDelta = 70%) then it will move up straight to center of the screen (XDelta =50% and YDelta is 40%). Then it will move to its upper left (10 dp from the left of the screen and 10 dp from the top of the screen) Sorry I can't post images due to my lack of reputation.

And here's my code in res/anim/card1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android" >
     <translate
            android:duration="200"
            android:fromXDelta="50%"
            android:fromYDelta="70%"
            android:toYDelta="40%" 
            android:toXDelta="50%"
            android:fillEnabled="true"/>
        <translate
            android:duration="100"
            android:fillEnabled="true"
            android:fromXDelta="50%"
            android:fromYDelta="40%"
            android:startOffset="200"
            android:toXDelta="10"
            android:toYDelta="10" />
    </set>

And code to get it work when clicking on the card

    Animation anim = AnimationUtils.loadAnimation(MainActivity.this,
                R.anim.card1);
    iv_card.startAnimation(anim);

... but it just don't animate the way I want. Please help me!!!!

SaravanaRaja
  • 3,228
  • 2
  • 21
  • 29
Androidizing
  • 87
  • 2
  • 11

1 Answers1

1

Check Out this (http://www.tktutorials.com/2013/07/animation-in-android-using-xml-files.html) this may help your need. Alter the translate.xml file as per your need, which is located in Res->anim->translate.xml

And solution for your posting Image. My suggestion is upload your pic in googleDrive, then change the share setting for the particular pic from private to Public on web and use the url Link to your question.

SaravanaRaja
  • 3,228
  • 2
  • 21
  • 29
  • 1
    Do no what happened to that like, here some of Useful link for animation @RuchirBaronia (https://harinathandroid1.wordpress.com/2012/07/20/toprightleftbottom/) (http://stackoverflow.com/questions/5151591/android-left-to-right-slide-animation) (http://www.androidhive.info/2013/06/android-working-with-xml-animations/) – SaravanaRaja Nov 27 '15 at 06:11