Created
August 1, 2017 13:29
-
-
Save EmmanuelGuther/e6a6d13a157e0ef027d47dfcdef236f8 to your computer and use it in GitHub Desktop.
ANDROID - Class to animate views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.os.Build; | |
import android.view.View; | |
import android.view.animation.AnimationUtils; | |
public class SimpleViewAnimation { | |
public static final int SLOW_ANIM = 1900; | |
public static final int FAST_ANIM = 800; | |
public static final int DELAY_ANIM_DEFAULT = 500; | |
public SimpleViewAnimation (Context context, View view, int animSpeed) { | |
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { | |
view.setAlpha(0f); | |
view.setScaleX(0.8f); | |
view.animate() | |
.alpha(1f) | |
.scaleX(1f) | |
.setStartDelay(500) | |
.setDuration(animSpeed) | |
.setInterpolator(AnimationUtils.loadInterpolator(context, | |
android.R.interpolator.fast_out_slow_in)); | |
} | |
} | |
public SimpleViewAnimation (Context context, View view, int animSpeed, int delayTime) { | |
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { | |
view.setAlpha(0f); | |
view.setScaleX(0.8f); | |
view.animate() | |
.alpha(1f) | |
.scaleX(1f) | |
.setStartDelay(delayTime) | |
.setDuration(animSpeed) | |
.setInterpolator(AnimationUtils.loadInterpolator(context, | |
android.R.interpolator.fast_out_slow_in)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment