android


ImageView to zoom out and scale the image animation in android


I want image to zoom out and scale as Twitter Splash screen animation but I am not able to first zoom out the image and scale. Here's is my code
imageView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
imageView.animate()
.setStartDelay(500)
.setDuration(1000)
.scaleX(20)
.scaleY(20)
.alpha(0);
}
});
You didn't mention scale from variable
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:fillAfter="true" >
<scale
xmlns:android="http://schemas.android.com/apk/res/android"
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" >
</scale>
</set>
You can do almost any animations with ObjectAnimator and it's very smooth.
Here is a sample code. In this case image will scale up from 1x to 2x, You can adjust the values as your need.Now if you want to scale down then change 2x to 0.5x which will scale down image to 50% of original image.
ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(imageView, "scaleX", 1.0f, 2.0f);
scaleXAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
scaleXAnimation.setDuration(1500);
ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(imageView, "scaleY", 1.0f, 2.0f);
scaleYAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
scaleYAnimation.setDuration(1500);
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(imageView, "alpha", 1.0F, 0F);
alphaAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
alphaAnimation.setDuration(1500);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(scaleXAnimation).with(scaleYAnimation).with(alphaAnimation);
animatorSet.setStartDelay(500);
animatorSet.start();

Related Links

Building a jar using gradle dependencies?
Android: what is the simplest way to mask a shape onto a View?
Using an auto-proxy configuration script with the android emulator
Displaying dynamic counter of timer when button is clicked in andorid
adb screenrecord command does not work on my Android TV
Android : How to get PendingIntent id for canceling pendingintent
Nativescript location module doesn't perform until real gps apps are also running
Center custom Font with canvas.DrawText()
Changing Android Manifest file for build automation [duplicate]
Checkbox status not being passed when dialog button pressed
How to use Android Resources in Application class?
android how to put communique from web to app
Push application-readable file to Android device
Does Google Playstore allow us to set a future date when publising/updating an app?
Android ListView Expand animation jumpy
DialogFragment Saving and Restoring state

Categories

HOME
sonarqube
assembly
facebook-oauth
api
eslint
c99
fpga
github-for-windows
ecmascript-6
shiro
newrelic
soa
permissions
hugo
spring-session
jtextpane
jquery-ui-sortable
android-securityexception
google-form
supervisor
package-managers
azure-powershell
esoteric-languages
intershop
html5-appcache
sigma.js
windows-xp
imagemap
surveymonkey
mat
oculus
apktool
inversion-of-control
android-things
quantlib
jaws
panoramas
gitlab-api
aws-codecommit
git-squash
rselenium
login-script
pdw-file-browser
baidu-map
searchkit
latitude-longitude
sim-toolkit
openalpr
android-augmented-reality
c9.io
stringtokenizer
outputcache
signal-strength
openresty
appdomain
cup
mach-o
rackspace-cloud
baidu
materialized-path-pattern
visual-studio-2008-sp1
simplepie
builtins
windows-azure-queues
avspeechsynthesizer
firebase-security
observablecollection
pre-build-event
data-protection
fuzzywuzzy
invoke-sqlcmd
piracy-prevention
rasterize
crouton-os
decimalformat
pypiserver
cgi-bin
avahi
snackbar
viewer
pseudo-class
crowd
sonarqube-5.0
device-tree
kissfft
high-resolution
sphinxql
device-width
failing-tests
predicatebuilder
jsr286
google-maps-mobile
lxr
web-application-project
xpsdocument
dsoframer

Resources

Encrypt Message