Simple tool which help you to implement activity transition for pre-Lollipop devices.
In your app build.gradle add
dependencies {
compile 'com.kogitune:pre-lollipop-activity-transition:0.0.1'
}
Start Activity in first activity.
findViewById(R.id.imageView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(MainActivity.this, SubActivity.class);
ActivityTransitionLauncher.with(MainActivity.this).from(v).launch(intent);
}
});
Receive intent in second activity.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub);
ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
}
If if you want the exit animation, you can do like this.
private ExitActivityTransition exitTransition;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub2);
exitTransition = ActivityTransition.with(getIntent()).to(findViewById(R.id.sub_imageView)).start(savedInstanceState);
}
@Override
public void onBackPressed() {
exitTransition.exit(this);
}
Sample Photo Luke Ma https://www.flickr.com/photos/lukema/12499338274/in/photostream/
DevBytes: Custom Activity Animations https://www.youtube.com/watch?v=CPxkoe2MraA
This project is released under the Apache License, Version 2.0.