本文整理汇总了Java中android.animation.Animator.setDuration方法的典型用法代码示例。如果您正苦于以下问题:Java Animator.setDuration方法的具体用法?Java Animator.setDuration怎么用?Java Animator.setDuration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.Animator
的用法示例。
在下文中一共展示了Animator.setDuration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: concealActivity
import android.animation.Animator; //导入方法依赖的package包/类
public static void concealActivity(final Activity activity, final int duration, final int centerX, int centerY) {
if (takeEffect) {
final View rootView = activity.findViewById(android.R.id.content);
Animator animator = ViewAnimationUtils.createCircularReveal(rootView, centerX, centerY, getMaxRadius(rootView) * 2, 0);
animator.setDuration(duration);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
rootView.setVisibility(View.GONE);
activity.finish();
activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
}
});
animator.start();
} else {
activity.finish();
}
}
示例2: show
import android.animation.Animator; //导入方法依赖的package包/类
/**
* 向四周伸张,直到完成显示。
*/
@SuppressLint("NewApi")
public static void show(View myView, float startRadius, long durationMills) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
myView.setVisibility(View.VISIBLE);
return;
}
int cx = (myView.getLeft() + myView.getRight()) / 2;
int cy = (myView.getTop() + myView.getBottom()) / 2;
int w = myView.getWidth();
int h = myView.getHeight();
// 勾股定理 & 进一法
int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;
Animator anim =
ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, finalRadius);
myView.setVisibility(View.VISIBLE);
anim.setDuration(durationMills);
anim.start();
}
示例3: startTranslationYAnimation
import android.animation.Animator; //导入方法依赖的package包/类
public static void startTranslationYAnimation(View view, long delay, long duration,
float endTranslationY, Interpolator interpolator) {
Animator translationAnim;
if (view.isHardwareAccelerated() && isSupportRenderNodeAnimator()) {
RenderNodeAnimator translationAnimRt = new RenderNodeAnimator(
RenderNodeAnimator.TRANSLATION_Y, endTranslationY);
translationAnimRt.setTarget(view);
translationAnim = translationAnimRt;
} else {
translationAnim = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y,
view.getTranslationY(), endTranslationY);
}
translationAnim.setInterpolator(interpolator);
translationAnim.setDuration(duration);
translationAnim.setStartDelay(delay);
translationAnim.start();
}
示例4: doCircularExitAnimation
import android.animation.Animator; //导入方法依赖的package包/类
/**
* Circular reveal exit animation
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doCircularExitAnimation() {
final int revealRadius = (int) Math.hypot(getWidth(), getHeight());
Animator exitAnimator = ViewAnimationUtils.createCircularReveal(this,
mCenterX, mCenterY, revealRadius, 0f);
exitAnimator.setDuration(mAnimationDuration);
exitAnimator.setInterpolator(AnimationUtils.loadInterpolator(mActivity,
android.R.interpolator.decelerate_cubic));
exitAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
removeView();
}
});
exitAnimator.start();
}
示例5: snapChild
import android.animation.Animator; //导入方法依赖的package包/类
private void snapChild(final View animView, final float targetLeft, float velocity) {
final boolean canBeDismissed = mCallback.canChildBeDismissed(animView);
AnimatorUpdateListener updateListener = new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
onTranslationUpdate(animView, (float) animation.getAnimatedValue(), canBeDismissed);
}
};
Animator anim = getViewTranslationAnimator(animView, targetLeft, updateListener);
if (anim == null) {
return;
}
int duration = SNAP_ANIM_LEN;
anim.setDuration(duration);
anim.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animator) {
mSnappingChild = false;
updateSwipeProgressFromOffset(animView, canBeDismissed);
mCallback.onChildSnappedBack(animView, targetLeft);
}
});
prepareSnapBackAnimation(animView, anim);
mSnappingChild = true;
anim.start();
}
示例6: hideView
import android.animation.Animator; //导入方法依赖的package包/类
private void hideView() {
final Pair<Float, Float> center = ViewUtils.getCenter(revealImage);
final Animator animator = ViewAnimationUtils.createCircularReveal(toolbarImageView,
center.first.intValue(), center.second.intValue(), toolbarImageView.getWidth(), 0);
animator.setDuration(TRANSITION_DURATION);
animator.start();
}
示例7: createAnimator
import android.animation.Animator; //导入方法依赖的package包/类
@Override
public Animator createAnimator(final ViewGroup sceneRoot,
TransitionValues startValues,
final TransitionValues endValues) {
Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
if (startValues == null || endValues == null || changeBounds == null)
return null;
// if (endValues.view instanceof ViewGroup) {
// ViewGroup vg = (ViewGroup) endValues.view;
// float offset = vg.getHeight() / 3;
// for (int i = 0; i < vg.getChildCount(); i++) {
// View v = vg.getChildAt(i);
// v.setTranslationY(offset);
// v.setAlpha(0f);
// v.animate()
// .alpha(1f)
// .translationY(0f)
// .setDuration(150)
// .setStartDelay(150)
// .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
// android.R.interpolator.fast_out_slow_in));
// offset *= 1.8f;
// }
// }
changeBounds.setDuration(500);
changeBounds.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(),
android.R.interpolator.fast_out_slow_in));
return changeBounds;
}
示例8: onPreDraw
import android.animation.Animator; //导入方法依赖的package包/类
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public boolean onPreDraw() {
heart.getViewTreeObserver().removeOnPreDrawListener(this);
final int w = heart.getWidth();
final int h = heart.getHeight();
Animator reveal = ViewAnimationUtils.createCircularReveal(heart,
w / 2, h,
0, (float)Math.sqrt(h*h + (w*w/4)));
reveal.setInterpolator(new FastOutSlowInInterpolator());
reveal.setDuration(800);
reveal.start();
return false;
}
示例9: hide
import android.animation.Animator; //导入方法依赖的package包/类
/**
* 由满向中间收缩,直到隐藏。
*/
@SuppressLint("NewApi")
public static void hide(final View myView, float endRadius, long durationMills) {
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
myView.setVisibility(View.INVISIBLE);
return;
}
int cx = (myView.getLeft() + myView.getRight()) / 2;
int cy = (myView.getTop() + myView.getBottom()) / 2;
int w = myView.getWidth();
int h = myView.getHeight();
// 勾股定理 & 进一法
int initialRadius = (int) Math.sqrt(w * w + h * h) + 1;
Animator anim =
ViewAnimationUtils.createCircularReveal(myView, cx, cy, initialRadius, endRadius);
anim.setDuration(durationMills);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
myView.setVisibility(View.INVISIBLE);
}
});
anim.start();
}
示例10: setSpeed
import android.animation.Animator; //导入方法依赖的package包/类
/**
* 设置每个动画对应的持续时间
*
* @param speed
*/
public void setSpeed(int speed) {
mSpeed = speed;
List<Animator> listAnimator = mAnimatorSet.getChildAnimations();
for (int i = 0; i < listAnimator.size(); i++) {
Animator a = listAnimator.get(i);
a.setDuration(parseSpeed(pathDistances.get(i)));
}
}
示例11: setDuration
import android.animation.Animator; //导入方法依赖的package包/类
@Override
public void setDuration(int duration) {
Animator a = mAnimator.get();
if(a != null) {
a.setDuration(duration);
}
}
示例12: animateButton
import android.animation.Animator; //导入方法依赖的package包/类
private void animateButton() {
/* Circular reveal the button */
int startRadius = 0;
int finalRadius = Math.max(maskView.getHeight(), maskView.getWidth());
final Animator anim = ViewAnimationUtils.createCircularReveal(maskView,
maskView.getRight(),
maskView.getHeight() / 2
, startRadius, finalRadius);
maskView.setVisibility(View.VISIBLE);
anim.setInterpolator(new FastOutSlowInInterpolator());
anim.setDuration(800);
anim.start();
// set the button text2+
buttonText.setText(R.string.continue_btn_text);
/* Animate the check image */
ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(checkImage, "rotation", 0f, 360f);
rotationAnimator.setDuration(400);
rotationAnimator.setInterpolator(new FastOutSlowInInterpolator());
int center = maskView.getRight() / 2;
int right = maskView.getRight();
int offSet = (right - center) / 2;
ObjectAnimator translateXInterpolator = ObjectAnimator.ofFloat(checkImage, "x", offSet + 10f);
translateXInterpolator.setDuration(400);
translateXInterpolator.setInterpolator(new DecelerateInterpolator());
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(rotationAnimator, translateXInterpolator);
animatorSet.start();
// for second time
count++;
}
示例13: createRevealAnimator
import android.animation.Animator; //导入方法依赖的package包/类
private Animator createRevealAnimator(FloatingActionButton dot, float offsetY){
ViewCompat.setElevation(dot,0);
dot.setVisibility(View.INVISIBLE);
lastDot=dot;
int cx=(int)(dot.getX()+dot.getHeight()/2);
int cy=(int)(dot.getY()+dot.getHeight()/2+offsetY);
int w = topPanel.getWidth();
int h = topPanel.getHeight();
final int endRadius = !isFolded?(int) Math.hypot(w, h):dot.getHeight()/2;
final int startRadius=isFolded?(int) Math.hypot(w, h):dot.getHeight()/2;
topPanel.setVisibility(View.VISIBLE);
Animator animator= ViewAnimationUtils.createCircularReveal(topPanel,cx,cy,startRadius,endRadius);
animator.setDuration(duration(R.integer.reveal_duration));
return animator;
}
示例14: hideMenu
import android.animation.Animator; //导入方法依赖的package包/类
private void hideMenu(int cx, int cy, float startRadius, float endRadius) {
List<Animator> animList = new ArrayList<>();
for (int i = arcLayout.getChildCount() - 1; i >= 0; i--) {
animList.add(createHideItemAnimator(arcLayout.getChildAt(i)));
}
animList.add(createHideItemAnimator(centerItem));
Animator revealAnim = createCircularReveal(menuLayout, cx, cy, startRadius, endRadius);
revealAnim.setInterpolator(new AccelerateDecelerateInterpolator());
revealAnim.setDuration(200);
revealAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
menuLayout.setVisibility(View.INVISIBLE);
}
});
animList.add(revealAnim);
AnimatorSet animSet = new AnimatorSet();
animSet.playSequentially(animList);
animSet.start();
}
示例15: showTop
import android.animation.Animator; //导入方法依赖的package包/类
private void showTop(View view) {
view.setVisibility(View.VISIBLE);
Animator iconAnim = ObjectAnimator.ofPropertyValuesHolder(view,
PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -view.getHeight(), 0f));
iconAnim.setDuration(VIEW_ANIMATION);
iconAnim.start();
}