下面列出了android.animation.AnimatorSet#setInterpolator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void showSearchPlacesButton(boolean show) {
if (show && searchAreaButton != null && searchAreaButton.getTag() == null) {
if (myLocation == null || userLocation == null || userLocation.distanceTo(myLocation) < 300) {
show = false;
}
}
if (searchAreaButton == null || show && searchAreaButton.getTag() != null || !show && searchAreaButton.getTag() == null) {
return;
}
searchAreaButton.setTag(show ? 1 : null);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(searchAreaButton, View.TRANSLATION_X, show ? 0 : -AndroidUtilities.dp(80)));
animatorSet.setDuration(180);
animatorSet.setInterpolator(CubicBezierInterpolator.EASE_OUT);
animatorSet.start();
}
private void newHideAnim() {
ObjectAnimator translationHide = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", 0,
mBottomBar.getTop());
ObjectAnimator alphaHide = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 1.0f, 0.0f);
translationHide.setDuration(200);
setHide = new AnimatorSet();
setHide.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
rootViewAlbumItems.setVisibility(View.GONE);
}
});
setHide.setInterpolator(new AccelerateInterpolator());
setHide.play(translationHide).with(alphaHide);
}
public eqlizerMain(Context context, int width, int height) {
super(context, width, height);
setBackgroundColor(mainBackground.Color0);
setPivotY(height*0.7f);
setPivotX(width*0.5f);
Ui.ef.clickPlay();
setAlpha(0);
Set = new AnimatorSet();
Set.setInterpolator(Ui.cd.TH);
Set.setDuration(200);
Set.playTogether(
ObjectAnimator.ofFloat(this, "Y",height * 0.5f, 0),
ObjectAnimator.ofFloat(this, "Alpha", 1.0F)
);
Set.start();
init();
}
public DisappearingAnimator(boolean removeDialog) {
mIsDialogClosing = removeDialog;
Animator sheetFader = ObjectAnimator.ofFloat(
mRequestView, View.ALPHA, mRequestView.getAlpha(), 0f);
Animator sheetTranslator = ObjectAnimator.ofFloat(
mRequestView, View.TRANSLATION_Y, 0f, mAnimatorTranslation);
AnimatorSet current = new AnimatorSet();
current.setDuration(DIALOG_EXIT_ANIMATION_MS);
current.setInterpolator(new FastOutLinearInInterpolator());
if (mIsDialogClosing) {
Animator scrimFader = ObjectAnimator.ofInt(mFullContainer.getBackground(),
AnimatorProperties.DRAWABLE_ALPHA_PROPERTY, 127, 0);
current.playTogether(sheetFader, sheetTranslator, scrimFader);
} else {
current.playTogether(sheetFader, sheetTranslator);
}
mSheetAnimator = current;
mSheetAnimator.addListener(this);
mSheetAnimator.start();
}
private void animateToolbarOpen(int openPercentHeight, int duration) {
ValueAnimator animator = ValueAnimator.ofInt(0, percentHeightToPx(openPercentHeight)).setDuration(duration);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
frameLayout.getLayoutParams().height = value.intValue();
frameLayout.requestLayout();
}
});
frameLayout.setVisibility(View.VISIBLE);
ViewCompat.setTranslationZ(frameLayoutContainerRL, 5f);
AnimatorSet set = new AnimatorSet();
set.play(animator);
set.setInterpolator(new AccelerateDecelerateInterpolator());
set.start();
}
@Override
public void onFocusChanged(View oldFocus, View newFocus) {
try {
if (newFocus instanceof AbsListView) {
return;
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.setInterpolator(new DecelerateInterpolator(1));
animatorSet.setDuration(mDurationTraslate);
animatorSet.playTogether(mAnimatorList);
for (Animator.AnimatorListener listener : mAnimatorListener) {
animatorSet.addListener(listener);
}
mAnimatorSet = animatorSet;
if (oldFocus == null) {
animatorSet.setDuration(0);
mTarget.setVisibility(View.VISIBLE);
}
animatorSet.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
private void hideRetry(){
if(retryAnim!=null)
retryAnim.cancel();
retrying=false;
//bottomButtons.setVisibility(View.VISIBLE);
ObjectAnimator colorAnim;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
} else {
colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
colorAnim.setEvaluator(new ArgbEvaluator());
}
AnimatorSet set=new AnimatorSet();
set.playTogether(
colorAnim,
ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
ObjectAnimator.ofFloat(endBtn, "translationX", 0),
ObjectAnimator.ofFloat(cancelBtn, "alpha", 0)//,
//ObjectAnimator.ofFloat(bottomButtons, "alpha", 1)
);
set.setStartDelay(200);
set.setDuration(300);
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
set.addListener(new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd(Animator animation){
cancelBtn.setVisibility(View.GONE);
endBtn.setEnabled(true);
retryAnim=null;
}
});
retryAnim=set;
set.start();
}
private void startAnimation() {
btContinue.setVisibility(View.VISIBLE);
stop.setVisibility(View.VISIBLE);
WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
Animator animatorStart = ObjectAnimator.ofFloat(start, "alpha", 1.0f, 0f);
AnimatorSet animatorSetStart = new AnimatorSet();
animatorSetStart.playTogether(animatorStart);
animatorSetStart.setInterpolator(new DecelerateInterpolator());
animatorSetStart.setDuration(1000);
animatorSetStart.start();
Animator animatorContinue1 = ObjectAnimator.ofFloat(btContinue, "alpha", 0f, 1.0f);
animatorContinue1.setDuration(3000);
Animator animatorContinue2 = ObjectAnimator.ofFloat(btContinue, "translationX", -width / 3, btContinue.getX());
animatorContinue2.setDuration(2000);
AnimatorSet animatorSetContinue = new AnimatorSet();
animatorSetContinue.playTogether(animatorContinue1, animatorContinue2);
animatorSetContinue.setInterpolator(new DecelerateInterpolator());
Animator animatorStop1 = ObjectAnimator.ofFloat(stop, "alpha", 0f, 1.0f);
animatorStop1.setDuration(3000);
Animator animatorStop2 = ObjectAnimator.ofFloat(stop, "translationX", width / 3, 0);
animatorStop2.setDuration(2000);
AnimatorSet animatorSetStop = new AnimatorSet();
animatorSetStop.playTogether(animatorStop1, animatorStop2);
animatorSetStop.setInterpolator(new DecelerateInterpolator());
animatorSetStart.start();
animatorSetStop.start();
animatorSetContinue.start();
start.setVisibility(View.GONE);
}
private void initAnimation() {
scaleXAnim = ObjectAnimator.ofFloat(floatingactionbutton_details,"scaleX",1.3f,0.8f,1.0f);
scaleYAnim = ObjectAnimator.ofFloat(floatingactionbutton_details,"scaleY",1.3f,0.8f,1.0f);
animatorSet = new AnimatorSet();
animatorSet.play(scaleXAnim).with(scaleYAnim);
animatorSet.setDuration(1000);
animatorSet.setInterpolator(new DecelerateInterpolator());
}
@NonNull
private Animator createElevationAnimator(float elevation, float translationZ) {
AnimatorSet set = new AnimatorSet();
set.play(ObjectAnimator.ofFloat(view, "elevation", elevation).setDuration(0))
.with(
ObjectAnimator.ofFloat(view, View.TRANSLATION_Z, translationZ)
.setDuration(ELEVATION_ANIM_DURATION));
set.setInterpolator(ELEVATION_ANIM_INTERPOLATOR);
return set;
}
private Animator getAnimator(View target){
AnimatorSet set = getEnterAnimtor(target);
ValueAnimator bezierValueAnimator = getBezierValueAnimator(target);
AnimatorSet finalSet = new AnimatorSet();
finalSet.playSequentially(set);
finalSet.playSequentially(set, bezierValueAnimator);
finalSet.setInterpolator(interpolators[random.nextInt(4)]);
finalSet.setTarget(target);
return finalSet;
}
@Override
public AnimatorSet createAnimatorSet() {
ViewHelper.setClipChildren(targetView, false);
AnimatorSet rotationSet = new AnimatorSet();
rotationSet.play(ObjectAnimator.ofFloat(targetView, View.ROTATION, targetView.getRotation() + degrees));
rotationSet.setInterpolator(interpolator);
rotationSet.setDuration(duration);
if (listener != null) {
rotationSet.addListener(listener);
}
return rotationSet;
}
public void animatePause() {
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(this, mPropertyPointAX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointAY, mBounds.top),
ObjectAnimator.ofFloat(this, mPropertyPointBX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointBY, mBounds.bottom),
ObjectAnimator.ofFloat(this, mPropertyPointCX, mBounds.right - shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointCY, mBounds.top),
ObjectAnimator.ofFloat(this, mPropertyPointDX, mBounds.right - shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointDY, mBounds.bottom),
ObjectAnimator.ofFloat(this, mPropertyPointEX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointEY, mBounds.centerY()),
ObjectAnimator.ofFloat(this, mPropertyPointFX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointFY, mBounds.centerY()),
ObjectAnimator.ofFloat(this, mRotationProperty, 0f, 1f),
ObjectAnimator.ofObject(this, mLineColorProperty, mArgbEvaluator, mPauseColor),
ObjectAnimator.ofObject(this, mBackgroundColorProperty, mArgbEvaluator, mPlayColor),
ObjectAnimator.ofFloat(this, mStrokeWidthProperty, mStrokeWidth)
);
set.setDuration(mAnimationDuration);
set.setInterpolator(ANIMATION_INTERPOLATOR);
set.start();
}
private AnimatorSet getRotationAnimator(final View targetView) {
AnimatorSet animator = new AnimatorSet();
animator.setDuration(1000);
animator.setInterpolator(new DecelerateInterpolator(1.5f));
ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(targetView, View.ROTATION, 0f, 45f);
animator.play(scaleXAnimator);
return animator;
}
private void showRetry() {
if (retryAnim != null)
retryAnim.cancel();
endBtn.setEnabled(false);
retrying = true;
cancelBtn.setVisibility(View.VISIBLE);
cancelBtn.setAlpha(0);
AnimatorSet set = new AnimatorSet();
ObjectAnimator colorAnim;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
} else {
colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
colorAnim.setEvaluator(new ArgbEvaluator());
}
set.playTogether(
ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1),
ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2),
colorAnim,
ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//,
//ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0),
//ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0),
//ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0)
);
set.setStartDelay(200);
set.setDuration(300);
set.setInterpolator(CubicBezierInterpolator.DEFAULT);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
//bottomButtons.setVisibility(View.GONE);
retryAnim = null;
endBtn.setEnabled(true);
}
});
retryAnim = set;
set.start();
}
@SuppressLint("DefaultLocale")
@Override
public void onEnterScreen() {
if (itemAnimationEnabled && enable && weather != null) {
int aqiColor = weather.getCurrent().getAirQuality().getAqiColor(progress.getContext());
ValueAnimator progressColor = ValueAnimator.ofObject(
new ArgbEvaluator(),
ContextCompat.getColor(context, R.color.colorLevel_1),
aqiColor
);
progressColor.addUpdateListener(animation -> progress.setProgressColor(
(Integer) animation.getAnimatedValue(), themeManager.isLightTheme()));
ValueAnimator backgroundColor = ValueAnimator.ofObject(
new ArgbEvaluator(),
themeManager.getLineColor(context),
ColorUtils.setAlphaComponent(aqiColor, (int) (255 * 0.1))
);
backgroundColor.addUpdateListener(animation ->
progress.setArcBackgroundColor((Integer) animation.getAnimatedValue())
);
ValueAnimator aqiNumber = ValueAnimator.ofObject(new FloatEvaluator(), 0, aqiIndex);
aqiNumber.addUpdateListener(animation -> {
progress.setProgress((Float) animation.getAnimatedValue());
progress.setText(String.format("%d", (int) progress.getProgress()));
});
attachAnimatorSet = new AnimatorSet();
attachAnimatorSet.playTogether(progressColor, backgroundColor, aqiNumber);
attachAnimatorSet.setInterpolator(new DecelerateInterpolator());
attachAnimatorSet.setDuration((long) (1500 + aqiIndex / 400f * 1500));
attachAnimatorSet.start();
adapter.executeAnimation();
}
}
@OnClick(R.id.activator) void activateAwareMotion(View target) {
// Cancel all concurrent events on view
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
target.cancelPendingInputEvents();
}
target.setEnabled(false);
// Coordinates of circle initial point
final ViewGroup parent = (ViewGroup) activatorMask.getParent();
final Rect bounds = new Rect();
final Rect maskBounds = new Rect();
target.getDrawingRect(bounds);
activatorMask.getDrawingRect(maskBounds);
parent.offsetDescendantRectToMyCoords(target, bounds);
parent.offsetDescendantRectToMyCoords(activatorMask, maskBounds);
// Put Mask view at circle 8initial points
maskElevation = activatorMask.getCardElevation();
activatorMask.setCardElevation(0);
activatorMask.setVisibility(View.VISIBLE);
activatorMask.setX(bounds.left - maskBounds.centerX());
activatorMask.setY(bounds.top - maskBounds.centerY());
circlesLine.setVisibility(View.INVISIBLE);
final int cX = maskBounds.centerX();
final int cY = maskBounds.centerY();
final float endRadius = (float) Math.hypot(maskBounds.width() * .5f, maskBounds.height() * .5f);
Animator circularReveal =
ViewAnimationUtils.createCircularReveal(activatorMask, cX, cY, target.getWidth() / 2,
endRadius, View.LAYER_TYPE_HARDWARE);
final float c0X = bounds.centerX() - maskBounds.centerX();
final float c0Y = bounds.centerY() - maskBounds.centerY();
AnimatorPath path = new AnimatorPath();
path.moveTo(c0X, c0Y);
path.curveTo(c0X, c0Y, 0, c0Y, 0, 0);
ObjectAnimator pathAnimator = ObjectAnimator.ofObject(this, "maskLocation", new PathEvaluator(),
path.getPoints().toArray());
AnimatorSet set = new AnimatorSet();
set.playTogether(circularReveal, pathAnimator);
set.setInterpolator(new FastOutSlowInInterpolator());
set.setDuration(SLOW_DURATION);
set.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationEnd(Animator animation) {
executeCardsSequentialAnimation();
activatorMask.setCardElevation(maskElevation);
}
});
set.start();
}
public void movePreviewFragment(float dy)
{
if (!inPreviewMode || transitionAnimationPreviewMode)
{
return;
}
float currentTranslation = containerView.getTranslationY();
float nextTranslation = -dy;
if (nextTranslation > 0)
{
nextTranslation = 0;
}
else if (nextTranslation < -AndroidUtilities.dp(60))
{
inPreviewMode = false;
nextTranslation = 0;
BaseFragment prevFragment = fragmentsStack.get(fragmentsStack.size() - 2);
BaseFragment fragment = fragmentsStack.get(fragmentsStack.size() - 1);
if (Build.VERSION.SDK_INT >= 21)
{
fragment.fragmentView.setOutlineProvider(null);
fragment.fragmentView.setClipToOutline(false);
}
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) fragment.fragmentView.getLayoutParams();
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
fragment.fragmentView.setLayoutParams(layoutParams);
presentFragmentInternalRemoveOld(false, prevFragment);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(
ObjectAnimator.ofFloat(fragment.fragmentView, "scaleX", 1.0f, 1.05f, 1.0f),
ObjectAnimator.ofFloat(fragment.fragmentView, "scaleY", 1.0f, 1.05f, 1.0f));
animatorSet.setDuration(200);
animatorSet.setInterpolator(new CubicBezierInterpolator(0.42, 0.0, 0.58, 1.0));
animatorSet.start();
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
fragment.setInPreviewMode(false);
}
if (currentTranslation != nextTranslation)
{
containerView.setTranslationY(nextTranslation);
invalidate();
}
}
public void dismiss() {
int childCount = getChildCount();
if (childCount > 1) {
float x = 0.5f * mEdge;
float y = 0.5f * mEdge;
Animator[] before = new Animator[childCount];
Animator[] after = new Animator[childCount - 1];
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
float pivotX = x - child.getLeft();
float pivotY = y - child.getTop();
float childX = 0.5f * child.getLeft() + child.getRight() * 0.5f;
float childY = 0.5f * child.getTop() + 0.5f * child.getBottom();
child.setPivotX(pivotX);
child.setPivotY(pivotY);
PropertyValuesHolder ca = PropertyValuesHolder.ofFloat("alpha", 1.0f, 0);
PropertyValuesHolder csx = PropertyValuesHolder.ofFloat("scaleX", 1.0f, 0);
PropertyValuesHolder csy = PropertyValuesHolder.ofFloat("scaleY", 1.0f, 0);
if (i == 0) {
before[i] = ObjectAnimator.ofPropertyValuesHolder(child, ca, csx, csy);
} else {
PropertyValuesHolder ctx = PropertyValuesHolder.ofFloat("translationX", 0, x - childX);
PropertyValuesHolder cty = PropertyValuesHolder.ofFloat("translationY", 0, y - childY);
PropertyValuesHolder cr = PropertyValuesHolder.ofFloat("rotation", 0, 360f);
before[i] = ObjectAnimator.ofPropertyValuesHolder(child, cr, ctx, cty);
PropertyValuesHolder cx = PropertyValuesHolder.ofFloat("translationX", x - childX, (childX - x) * 10);
PropertyValuesHolder cy = PropertyValuesHolder.ofFloat("translationY", y - childY, (childY - y) * 10);
after[i - 1] = ObjectAnimator.ofPropertyValuesHolder(child, cx, cy);
}
}
AnimatorSet set = new AnimatorSet();
AnimatorSet first = new AnimatorSet();
AnimatorSet last = new AnimatorSet();
first.playTogether(before);
last.playTogether(after);
set.setDuration(ANIM_DISMISS_DURATION);
set.setInterpolator(new DecelerateInterpolator());
set.play(first).before(last);
set.start();
}
}
public void animatePlay() {
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(this, mPropertyPointAX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointAY, mBounds.top),
ObjectAnimator.ofFloat(this, mPropertyPointBX, mBounds.right + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointBY, mBounds.centerY()),
ObjectAnimator.ofFloat(this, mPropertyPointCX, mBounds.right + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointCY, mBounds.centerY()),
ObjectAnimator.ofFloat(this, mPropertyPointDX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointDY, mBounds.bottom),
ObjectAnimator.ofFloat(this, mPropertyPointEX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointEY, mBounds.bottom),
ObjectAnimator.ofFloat(this, mPropertyPointFX, mBounds.left + shiftY),
ObjectAnimator.ofFloat(this, mPropertyPointFY, mBounds.top),
ObjectAnimator.ofFloat(this, mRotationProperty, 0f, 1f),
ObjectAnimator.ofObject(this, mLineColorProperty, mArgbEvaluator, mPlayColor),
ObjectAnimator.ofObject(this, mBackgroundColorProperty, mArgbEvaluator, mPauseColor),
ObjectAnimator.ofFloat(this, mStrokeWidthProperty, mStrokeWidth * 5/7)
);
set.setDuration(mAnimationDuration);
set.setInterpolator(ANIMATION_INTERPOLATOR);
set.start();
}