Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - Sliding fragments when click list item
    primarykey
    data
    text
    <p>I'm trying to implement the sliding animation to transit from fragment1 to fragment2, like <a href="https://dl.dropboxusercontent.com/u/106274374/slide.png" rel="nofollow noreferrer">this image</a>.</p> <p>Firstly, I tried to implement xml with set and translate, but I got RuntimeException "Unknown animator name translate". </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator"&gt; &lt;translate android:fromXDelta="0%p" android:toXDelta="-100%p" android:duration="500"&gt; &lt;/translate&gt; &lt;/set&gt; </code></pre> <p>Secondly, I tried to solve problem by using a class that extends framelayout, and add "getXFraction" and "setXFraction" method, like <a href="https://stackoverflow.com/questions/16235690/android-making-translations-and-objectanimator-on-the-same-xml-file">this post</a> </p> <pre><code>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 &gt; 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 &gt; 0) ? (yFraction * height) : -9999); } } </code></pre> <p>But I still don't know How should I use SlidingFrameLayout? Please help me. T___T</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload