Closed MarcHe124 closed 5 years ago
can anyone answer how to do this?
@MarcHe124 , @happyho3ein
Intent intent = new Intent(context, AnyActivity.class);
ActivityOptions options =
ActivityOptions.makeCustomAnimation(activity, R.anim.slide_in_down, R.anim.none);
ActivityCompat.startActivity(activity, intent, options.toBundle());
slide_in_down.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="100%p"
android:toYDelta="0"/>
AnyActivity.class
@Override
protected void onPause() {
super.onPause();
overridePendingTransition(R.anim.none, R.anim.slide_out_down);
}
slide_out_down.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="300"
android:fromYDelta="0%p"
android:toYDelta="100%p"/>
Basically you want to horizontally scroll between activities like you do with a viewpager and fragments?
You could hook into the SlidrListener
that you can configure when attaching to an activity and override it's boolean onSlideClosed()
method and do what you want when the slide is completed:
e.g.
@Override
public boolean onSlideClosed() {
startActivity(Intent(...));
finish();
return true; // Important so as to override the default behaviour
}
However, the library isn't currently capable of launching different activities based on the direction of the slide.
Wonder if it supports start a new activity when swiping with minimum code modification.