I am trying to implement a rolling animation to go from fragment1 to fragment2, for example this image .
First, I tried to implement xml using set and translate, but I got a RuntimeException "Unknown animator translator name".
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"> <translate android:fromXDelta="0%p" android:toXDelta="-100%p" android:duration="500"> </translate> </set>
Secondly, I tried to solve the problem using a class that extends the scope and adds the getXFraction and setXFraction method, for example this post
public class SlidingFrameLayout extends FrameLayout { private static final String TAG = SlidingFrameLayout.class.getName(); public SlidingFrameLayout(Context context) { super(context); } public SlidingFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public float getXFraction() { final int width = getWidth(); if(width != 0) return getX() / getWidth(); else return getX(); } public void setXFraction(float xFraction) { final int width = getWidth(); setX((width > 0) ? (xFraction * width) : -9999); } public float getYFraction() { final int height = getHeight(); if(height != 0) return getY() / getHeight(); else return getY(); } public void setYFraction(float yFraction) { final int height = getHeight(); setY((height > 0) ? (yFraction * height) : -9999); } }
But I still donβt know. How to use SlidingFrameLayout? Please help me. T ___ T
source share