本文整理汇总了Java中android.animation.Animator类的典型用法代码示例。如果您正苦于以下问题:Java Animator类的具体用法?Java Animator怎么用?Java Animator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Animator类属于android.animation包,在下文中一共展示了Animator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBind
import android.animation.Animator; //导入依赖的package包/类
@Override
public void onBind(Target view, Value o, final OnBindListener onBindListener) {
ObjectAnimator animatorX = ObjectAnimator.ofFloat(view, View.ROTATION, 0f, 10f);
ObjectAnimator animatorY = ObjectAnimator.ofFloat(view, View.ROTATION_X, 0f, 90f);
AnimatorSet set = new AnimatorSet();
set.setInterpolator(new AccelerateInterpolator(2f));
set.setDuration(300);
set.setStartDelay(80 * count);
set.playTogether(animatorX, animatorY);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
onBindListener.onBindDone();
}
});
set.start();
count++;
}
示例2: showIcons
import android.animation.Animator; //导入依赖的package包/类
private void showIcons(final boolean show) {
for (int i = 0; i < getChildCount(); i++) {
final View view = getChildAt(i);
int translation = menuAnchor == MENU_ANCHOR_BOTTOM ? view.getHeight() : -view.getHeight();
view.setTranslationY(show ? translation : 0f);
view.setScaleX(show ? 0f : 1f);
view.setScaleY(show ? 0f : 1f);
view.setVisibility(VISIBLE);
view.setAlpha(show ? 0f : 1f);
view.animate()
.scaleX(show ? 1f : 0f)
.scaleY(show ? 1f : 0f)
.translationY(0f)
.alpha(show ? 1f : 0f)
.setInterpolator(DECELERATE_INTERPOLATOR)
.setDuration(show ? animationDuration / 2 : animationDuration / 3)
.setStartDelay(show ? animationDuration / 3 : 0)
.setListener(new AnimatorListenerAdapter() {
@Override public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
view.setVisibility(show ? VISIBLE : GONE);
}
})
.start();
}
}
示例3: onBindViewHolder
import android.animation.Animator; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (position < getItemCount() && (customHeaderView != null ? position <= stringList.size() : position < stringList.size()) && (customHeaderView != null ? position > 0 : true)) {
((ViewHolder) holder).textViewSample.setText(stringList.get(customHeaderView != null ? position - 1 : position));
// ((ViewHolder) holder).itemView.setActivated(selectedItems.get(position, false));
}
if (!isFirstOnly || position > mLastPosition) {
for (Animator anim : getAdapterAnimations(holder.itemView, AdapterAnimationType.ScaleIn)) {
anim.setDuration(mDuration).start();
anim.setInterpolator(mInterpolator);
}
mLastPosition = position;
} else {
ViewHelper.clear(holder.itemView);
}
}
示例4: animateInFrameDetails
import android.animation.Animator; //导入依赖的package包/类
private void animateInFrameDetails() {
frameDetails.setVisibility(View.VISIBLE);
ViewUtils.onLaidOut(frameDetails, new Runnable() {
@Override
public void run() {
ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 0.4f, 1f);
ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, frameDetails.getHeight() * 0.3f, 0f);
AnimatorSet set = new AnimatorSet();
set.playTogether(alpha, translate);
set.setDuration(ANIM_DURATION);
set.setInterpolator(new LinearOutSlowInInterpolator());
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
frameMaster.setVisibility(View.GONE);
}
});
set.start();
}
});
}
示例5: runIconScale
import android.animation.Animator; //导入依赖的package包/类
private void runIconScale(int delay, @DrawableRes int drawable, int color){
soundPlay.animate()
.scaleY(0)
.scaleX(0)
.setDuration(duration(R.integer.short_delay))
.setStartDelay(delay)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
trackTitle.setTextColor(color);
soundPlay.setImageDrawable(ContextCompat.getDrawable(getContext(),drawable));
soundPlay.animate()
.scaleX(1)
.scaleY(1)
.setDuration(duration(R.integer.scale_duration))
.setListener(null).start();
}
}).start();
}
示例6: getAnimators
import android.animation.Animator; //导入依赖的package包/类
@Override
public List<Animator> getAnimators() {
final List<Animator> animations = new ArrayList<>();
calculate();
if (mCameraDistance != null) {
final ValueAnimator animator = ValueAnimator.ofFloat(mCurrentCameraDistance, mCameraDistance);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
viewToMove.setCameraDistance((float) valueAnimator.getAnimatedValue());
}
});
animations.add(animator);
}
return animations;
}
示例7: createAnimation
import android.animation.Animator; //导入依赖的package包/类
public List<Animator> createAnimation() {
List<Animator> animators = new ArrayList<>();
int[] delays = new int[]{120, 240, 360};
for (int i = 0; i < 3; i++) {
final int index = i;
ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.3f, 1);
scaleAnim.setDuration(750);
scaleAnim.setRepeatCount(-1);
scaleAnim.setStartDelay(delays[i]);
scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
scaleFloats[index] = (float) animation.getAnimatedValue();
postInvalidate();
}
});
scaleAnim.start();
animators.add(scaleAnim);
}
return animators;
}
示例8: createEnterTabSwitcherModeAnimation
import android.animation.Animator; //导入依赖的package包/类
private ObjectAnimator createEnterTabSwitcherModeAnimation() {
ObjectAnimator enterAnimation =
ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f);
enterAnimation.setDuration(TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS);
enterAnimation.setInterpolator(new LinearInterpolator());
enterAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// This is to deal with the view going invisible when resuming the activity and
// running this animation. The view is still there and clickable but does not
// render and only a layout triggers a refresh. See crbug.com/306890.
if (!mToggleTabStackButton.isEnabled()) requestLayout();
}
});
return enterAnimation;
}
示例9: setDimVisibility
import android.animation.Animator; //导入依赖的package包/类
private void setDimVisibility(final boolean visible) {
Animator animator;
if (visible) {
dimView.setVisibility(VISIBLE);
animator = ObjectAnimator.ofFloat(dimView, "alpha", 0.0f, 1.0f);
} else {
animator = ObjectAnimator.ofFloat(dimView, "alpha", 1.0f, 0.0f);
}
animator.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animation) {
if (!visible) {
dimView.setVisibility(GONE);
}
}
});
animator.setDuration(200);
animator.start();
}
示例10: 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();
}
示例11: hideRecordedAudioPanel
import android.animation.Animator; //导入依赖的package包/类
private void hideRecordedAudioPanel() {
audioToSendPath = null;
audioToSend = null;
audioToSendMessageObject = null;
AnimatorSet AnimatorSet = new AnimatorSet();
AnimatorSet.playTogether(
ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)
);
AnimatorSet.setDuration(200);
AnimatorSet.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Animator animation) {
recordedAudioPanel.setVisibility(GONE);
}
});
AnimatorSet.start();
}
示例12: fadeOut
import android.animation.Animator; //导入依赖的package包/类
private void fadeOut() {
contentView.setAlpha(0f);
contentView.setVisibility(View.VISIBLE);
contentView.animate()
.alpha(1f)
.setDuration(getResources().getInteger(
android.R.integer.config_longAnimTime))
.setListener(null);
loadingView.animate()
.alpha(0f)
.setDuration(getResources().getInteger(
android.R.integer.config_longAnimTime))
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
loadingView.setVisibility(View.GONE);
}
});
}
示例13: exitReveal
import android.animation.Animator; //导入依赖的package包/类
private void exitReveal(final View icon, final View toolbar) {
// get the center for the clipping circle
int cx = getRelativeLeft(icon) + icon.getMeasuredWidth() / 2;
int cy = getRelativeTop(icon);
// get the initial radius for the clipping circle
int initialRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());
// create the animation (the final radius is zero)
Animator anim =
ViewAnimationUtils.createCircularReveal(toolbar, cx, cy, initialRadius, 0);
// make the view invisible when the animation is done
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
toolbar.setVisibility(View.INVISIBLE);
}
});
anim.setDuration(Constant.SEARCH_REVEAL_DURATION);
// start the animation
anim.start();
}
示例14: performShowAnimation
import android.animation.Animator; //导入依赖的package包/类
private void performShowAnimation() {
contextMenuView.setPivotX(contextMenuView.getWidth() / 2);
contextMenuView.setPivotY(contextMenuView.getHeight());
contextMenuView.setScaleX(0.1f);
contextMenuView.setScaleY(0.1f);
contextMenuView.animate()
.scaleX(1f).scaleY(1f)
.setDuration(150)
.setInterpolator(new OvershootInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
isContextMenuShowing = false;
}
});
}
示例15: Play
import android.animation.Animator; //导入依赖的package包/类
void Play(int val){
final ImageView iv = top;
top = btm;
btm = creatImg();
btm.setImageBitmap(BM);
addView(btm,0);
Set = new AnimatorSet();
Set.setInterpolator(Ui.cd.TH);
Set.playTogether(ObjectAnimator.ofFloat(iv, "X",val));
Set.setDuration(500).start();
Set.addListener(new animLis(){
@Override
public void onAnimationEnd(Animator animation) {
imgSlider.this.removeView(iv);
}
});
}