Reputation: 55
I creating an application with few buttons when I click each buttons i want to go to new activity with zoom in animation from that particular clicked button frame.I achieved this by using overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);
Now my problem,it's not perfect in all devices I guess it's because of Pivot values how can i set this animation from button frames for all devices.
My zoom_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@string/animation_duration"
android:fromXScale="0.9999"
android:fromYScale="0.15"
android:pivotX="24%"
android:pivotY="77.5%"
android:toXScale="1"
android:toYScale="1" >
</scale>
</set>
My zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
>
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="100%"
android:pivotY="100%"
android:toXScale="1"
android:toYScale="1" >
</scale>
</set>
Upvotes: 2
Views: 1497
Reputation: 55
I found one solution and its worked for me paste the below code inside button click:
Intent i = new Intent(Currentactivity.this, Nextactivity.class);
Bundle b = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//b = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(),
// view.getHeight()).toBundle();
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
bitmap.eraseColor(Color.parseColor("#308cf8"));
b = ActivityOptions.makeThumbnailScaleUpAnimation(v, bitmap, 0, 0).toBundle();
}
startActivity(i, b);
Upvotes: 1