I have code of normally zoom in and zoom out animation between two activities, but I want something different. I have five buttons on my first activity if I click on first button then zoom in would be starts from position of first button only instead of zooming from centre. Please help me.
EDIT : Zoom should start from the button I clicked as a centre.
Pinch 2 or more fingers together or apart to adjust zoom. To zoom temporarily, quickly tap the screen 3 times and hold down your finger on the third tap. Drag your finger to move around the screen. Lift your finger to zoom out.
Tap anywhere on the screen, except the keyboard or navigation bar. Drag 2 fingers to move around the screen. Pinch with 2 fingers to adjust zoom. To stop magnification, use your magnification shortcut again.
In Android, Zoom Control is a class that has some set of methods that are used to control the zoom functionality. It has two buttons that are used to control the zoom functionality (ie Zoom In and Zoom Out). Zoom Control Class has been deprecated in API Version 29.
You can use this method after running the command to start your new activity,
startActivity(intent);
overridePendingTransition(animation_in_goes_here,animation_out_goes_here);
Then you may replace your animations above, replacing the animation_in_goes_here
with the animation resource you need for the activity that you have newly started and replacing animation_out_goes_here
with the animation resource for the activity that you are leaving from. This will give you the switching effects.
zoom_in.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<scale
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="3"
android:toYScale="3"/>
</set>
zoom_out.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true">
<scale
android:duration="1000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5"/>
</set>
Hope this helped to answer your question.
Zoom In
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="0"
android:fromYScale="0"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5">
</scale>
Zoom Out
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="2.1"
android:fromYScale="2.1"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="3000"
android:toXScale="0"
android:toYScale="0">
</scale>
I think you have to do as follow
Put animation descriptions into res/anim folder
object.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_enter));
object.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.zoom_exit));
You can use android sdk sample animations supplied by google under Apache 2.0 licence
Or refer this which uses scaling based zooming which is easier than the former
http://developer.android.com/training/animation/zoom.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With