1

I have one LinearLayout. My layout first time is gone and on button click i visible it with left to right animation.this is my source:

 public void ShowSlideMenu(LinearLayout layout)
{
    if(layout.getVisibility()==View.GONE)
    {
       if(LeftSwipe==null)
           LeftSwipe=AnimationUtils.loadAnimation(getActivity(),R.anim.slide_menu_lefttoright);
        layout.startAnimation(LeftSwipe);
        layout.setVisibility(View.VISIBLE);          
    }


}

this is xml animation code:

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="true">
<translate
    android:duration="@android:integer/config_mediumAnimTime"
    android:fromXDelta="100%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="0%" />

animation working perfect but now i want to add Easing effect. i read material design animation and i try to recive like this easing effect

https://www.google.com/design/spec/animation/authentic-motion.html#authentic-motion-mass-weight

and also like this

http://api.jqueryui.com/easings/ if anyone knows solution please help me thanks everyone

Shahzeb
  • 3,696
  • 4
  • 28
  • 47
donoachua
  • 193
  • 2
  • 16
  • First see related questions http://stackoverflow.com/questions/25443271/easing-effect-for-rotate-animation-in-android, http://stackoverflow.com/questions/22896605/how-to-apply-easing-animation-function-on-view-in-android and http://stackoverflow.com/questions/17028705/why-there-is-easing-effect-on-my-rotating-animation. Also, see http://fixabc.xyz/question/25443271/easing-effect-for-rotate-animation-in-android. – Mihai8 Oct 04 '15 at 13:06
  • i tryed custom Interpolator but i don't know how to recive easing effect with getInterpolation method @ user1929959 – donoachua Oct 04 '15 at 13:24

1 Answers1

2

A solution to this should be adding an interpolator to your animation set.

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:interpolator="@android:anim/decelerate_interpolator"
    android:shareInterpolator="true">

       <translate
          android:duration="@android:integer/config_mediumAnimTime"
          android:fromXDelta="100%"
          android:fromYDelta="0%"
          android:toXDelta="0%"
          android:toYDelta="0%" />
</set>

The interpolator will take your animation and change its speed over the duration of the animation. In the example I chose a decelerate interpolator that makes the animation starting fast and then getting slower and slower during the time of the animation.

Janusz
  • 187,060
  • 113
  • 301
  • 369