1

I want to custom fragment animation which make it should look like default animation that startActivity does.
It's some think like this:

enter image description here

I tried to search for default activity animation like this, but it doesn't work.
Does anyone know how to implement this kind of modal animation like above and put into setCustomAnimations of FragmentManager?

ductran
  • 10,043
  • 19
  • 82
  • 165

1 Answers1

0

For this you have to use android support fragments and supportFragmentManager and add like this

  1. Addd these files in res/anim folder

overshoot_slide_down

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
    android:duration="@android:integer/config_mediumAnimTime"
    android:fromXDelta="0%"
    android:fromYDelta="0%"
    android:toXDelta="0%"
    android:toYDelta="100%" />
</set>

overshoot_slide_up

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/overshoot_interpolator">
<translate
    android:duration="@android:integer/config_mediumAnimTime"
    android:fromXDelta="0%"
    android:fromYDelta="100%"
    android:toXDelta="0%"
    android:toYDelta="0%" />
</set>
  1. Call this method in java file

    getSupportFragmentManager()
    .beginTransaction()
    .setCustomAnimations(R.anim.overshoot_slide_up, 0,  0, R.anim.overshoot_slide_down)
    .add(container, fragment, tag).commit();
    
Devil10
  • 1,853
  • 1
  • 18
  • 22
  • Thanks, but it looks incorrectly. And the animation is very laggy – ductran Aug 17 '18 at 15:08
  • it isn't smooth, suddenly it appears. And animation doesn't like what I want – ductran Aug 17 '18 at 15:23
  • since its an overshoot interpolator in working which provides zig-zag fast motion. Just remove the interpolator from the animation xml file and increase the duration as per your requirement. Definitely will help you – Devil10 Aug 17 '18 at 15:27