Animate in Android

Here is the problem. I want to glide from left to right (from right to left in this code below ...) so please help me with the animation (XML Animation is the opposite of this) ... (My current task is done correctly when the button is clicked ...)

Here is the source ...

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button btnopen = (Button)findViewById(R.id.btnWindowAnimation);

    btnopen.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View v) {

    Intent i = new Intent(MainActivity.this, SecondActivity.class);

    Bundle bundle =ActivityOptions.makeCustomAnimation(getApplicationContext(), `              `R.anim.animation,R.anim.animation2).toBundle();
    startActivity(i, bundle);

    }
    });

}

1. Here Animation 1

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500"/>

2. Here Animation 2

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0"
android:toXDelta="-50%p"
android:duration="500"/>
+3
source share
2 answers

here is the answer ... 1.

 <translate 
     android:fromXDelta="-100%" 
     android:toXDelta="0%"
     android:duration="500"/>
</set>

2. And here is the second xml

<translate
 android:fromXDelta="0%"
  android:toXDelta="100%"
  android:duration="500" />
</set>
+2
source

This is for animation from left to right:

<set xmlns:android="http://schemas.android.com/apk/res/android"
 android:shareInterpolator="false">
 <translate android:fromXDelta="-100%" android:toXDelta="0%"
         android:fromYDelta="0%" android:toYDelta="0%"
         android:duration="700"/>
</set>

This is for animation from right to left:

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

Check out the link .

+3
source

All Articles