下面列出了android.view.animation.CycleInterpolator#android.view.animation.OvershootInterpolator 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
void display(float x, float y) {
this.startPositionX = x;
this.startPositionY = y;
recordButtonFab.setVisibility(View.VISIBLE);
AnimationSet animation = new AnimationSet(true);
animation.addAnimation(new TranslateAnimation(Animation.ABSOLUTE, 0,
Animation.ABSOLUTE, 0,
Animation.ABSOLUTE, 0,
Animation.ABSOLUTE, 0));
animation.addAnimation(new ScaleAnimation(.5f, 1f, .5f, 1f,
Animation.RELATIVE_TO_SELF, .5f,
Animation.RELATIVE_TO_SELF, .5f));
animation.setDuration(ANIMATION_DURATION);
animation.setInterpolator(new OvershootInterpolator());
recordButtonFab.startAnimation(animation);
}
private void display(float x) {
this.startPositionX = x;
this.lastPositionX = x;
recordButtonFab.setVisibility(VISIBLE);
recordButtonFab.setX(getWidthAdjustment() + getOffset(x));
AnimationSet animation = new AnimationSet(true);
ScaleAnimation scaleAnimation = new ScaleAnimation(0.5f, 1f, 0.5f, 1f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
animation.addAnimation(scaleAnimation);
animation.setFillBefore(true);
animation.setFillAfter(true);
animation.setDuration(ANIMATION_DURATION);
animation.setInterpolator(new OvershootInterpolator());
recordButtonFab.startAnimation(animation);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_albums, container, false);
ButterKnife.bind(this, v);
int spanCount = columnsCount();
// spacingDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, getContext()), true);
spacingDecoration = new GridSpacingItemDecoration(spanCount, Measure.pxToDp(3, mContext), true);
mAlbumsRecyclerView.setHasFixedSize(true);
mAlbumsRecyclerView.addItemDecoration(spacingDecoration);
mAlbumsRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), spanCount));
if (Prefs.animationsEnabled()) {
mAlbumsRecyclerView.setItemAnimator(
AnimationUtils.getItemAnimator(
new LandingAnimator(new OvershootInterpolator(1f))
));
}
mAdapter = new AlbumsAdapter(getContext(), this);
refresh.setOnRefreshListener(this::displayAlbums);
mAlbumsRecyclerView.setAdapter(mAdapter);
return v;
}
/**
* アクションする削除アイコンの設定を更新します。
*
* @param width 対象となるViewの幅
* @param height 対象となるViewの高さ
* @param shape 対象となるViewの形状
*/
void updateActionTrashIcon(float width, float height, float shape) {
// アクションする削除アイコンが設定されていない場合は何もしない
if (!hasActionTrashIcon()) {
return;
}
// 拡大率の設定
mAnimationHandler.mTargetWidth = width;
mAnimationHandler.mTargetHeight = height;
final float newWidthScale = width / mActionTrashIconBaseWidth * shape;
final float newHeightScale = height / mActionTrashIconBaseHeight * shape;
mActionTrashIconMaxScale = Math.max(newWidthScale, newHeightScale);
// ENTERアニメーション作成
mEnterScaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mActionTrashIconView, PropertyValuesHolder.ofFloat(ImageView.SCALE_X, mActionTrashIconMaxScale), PropertyValuesHolder.ofFloat(ImageView.SCALE_Y, mActionTrashIconMaxScale));
mEnterScaleAnimator.setInterpolator(new OvershootInterpolator());
mEnterScaleAnimator.setDuration(TRASH_ICON_SCALE_DURATION_MILLIS);
// Exitアニメーション作成
mExitScaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mActionTrashIconView, PropertyValuesHolder.ofFloat(ImageView.SCALE_X, 1.0f), PropertyValuesHolder.ofFloat(ImageView.SCALE_Y, 1.0f));
mExitScaleAnimator.setInterpolator(new OvershootInterpolator());
mExitScaleAnimator.setDuration(TRASH_ICON_SCALE_DURATION_MILLIS);
}
private void startShowContinueIconAnimations() {
Animation mScaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Animation mRotateAnimation = new RotateAnimation(
0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
mRotateAnimation.setRepeatCount(0);
AnimationSet mAnimations = new AnimationSet(true);
mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
mAnimations.setFillAfter(true);
mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
mAnimations.addAnimation(mScaleAnimation);
mAnimations.addAnimation(mRotateAnimation);
mContinueIcon.startAnimation(mAnimations);
}
private void startHideContinueIconAnimations() {
Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Animation mRotateAnimation = new RotateAnimation(
0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
mRotateAnimation.setRepeatCount(0);
AnimationSet mAnimations = new AnimationSet(true);
mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
mAnimations.setFillAfter(true);
mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
mAnimations.addAnimation(mScaleAnimation);
mAnimations.addAnimation(mRotateAnimation);
mContinueIcon.startAnimation(mAnimations);
}
private void setupLayout() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("behavior", BehaviorSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, true).get())
.add("progress", ProgressSubFragment.class)
.add("background", BackgroundSubFragment.class, new Bundler().putBoolean(OFFSET_STATE_ARG, true).get())
.add("text", TextSubFragment.class)
.create());
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(3);
mTAbs.setViewPager(mViewPager);
shadowColor = Color.WHITE;
blur = distX = distY = 2f;
}
private void setupLayout() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("behavior", BehaviorSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, true).get())
.add("progress bar", ProgressSubFragment.class, new Bundler().putBoolean(BAR_STATE_ARG, true).get())
.add("background bar", BackgroundBarSubFragment.class)
.add("background", BackgroundSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, false).get())
.add("text", TextSubFragment.class)
.create());
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(4);
mTAbs.setViewPager(mViewPager);
shadowColor = Color.WHITE;
blur = distX = distY = 2f;
}
private void setupLayout() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
getSupportFragmentManager(), FragmentPagerItems.with(this)
.add("behavior", BehaviorSubFragment.class, new Bundler().putBoolean(ORIENTATION_STATE_ARG, false).get())
.add("progress", ProgressSubFragment.class)
.add("background", BackgroundSubFragment.class, new Bundler().putBoolean(OFFSET_STATE_ARG, true).get())
.add("text", TextSubFragment.class)
.create());
mViewPager.setAdapter(adapter);
mViewPager.setOffscreenPageLimit(3);
mTAbs.setViewPager(mViewPager);
shadowColor = Color.WHITE;
blur = distX = distY = 2f;
}
private void showFab() {
shuffleButton.animate()
.setDuration(500)
.setInterpolator(new OvershootInterpolator())
.scaleX(1)
.scaleY(1)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
})
.start();
shuffleButton.setVisibility(View.VISIBLE);
shuffleButton.setEnabled(true);
}
private void createRotatingDrawable() {
RotatingDrawable dr = new RotatingDrawable(menuButtonIcon);
final OvershootInterpolator interpolator = new OvershootInterpolator();
final ObjectAnimator collapseAnimator = ObjectAnimator
.ofFloat(dr, "rotation", EXPANDED_PLUS_ROTATION, COLLAPSED_PLUS_ROTATION);
final ObjectAnimator expandAnimator = ObjectAnimator
.ofFloat(dr, "rotation", COLLAPSED_PLUS_ROTATION, EXPANDED_PLUS_ROTATION);
collapseAnimator.setInterpolator(interpolator);
expandAnimator.setInterpolator(interpolator);
expandAnimation.play(expandAnimator);
collapseAnimation.play(collapseAnimator);
menuButton.setImageDrawable(dr);
rotatingDrawable = dr;
}
private void showFab() {
playSongs.animate()
.setDuration(500)
.setInterpolator(new OvershootInterpolator())
.scaleX(1)
.scaleY(1)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
})
.start();
playSongs.setVisibility(View.VISIBLE);
playSongs.setEnabled(true);
}
AnimationTask() {
if (mIsAnimationLocked)
throw new RuntimeException("Returning to user's finger. Avoid animations while mIsAnimationLocked flag is set.");
mDestX = calculateX();
mDestY = calculateY();
mDynamicUpdate = null;
setAnimationFinishedListener(new AnimationFinishedListener() {
@Override
public void onAnimationFinished() {
adjustInactivePosition();
}
});
float velocityX = calculateVelocityX();
float velocityY = calculateVelocityY();
mTension += Math.sqrt(sqr(velocityX) + sqr(velocityY)) / 200;
mInterpolator = new OvershootInterpolator(mTension);
mCurrentPosX = mDestX;
mCurrentPosY = mDestY;
}
@Override
public void setData(HotMovieBean.SubjectsBean data) {
super.setData(data);
ImageLoader.load(data.getImages().getLarge(), ivRanking, 200);
tvRankingTitle.setText(data.getTitle());
tvDirectContent.setText(StringFormatUtil.formatName(data.getDirectors()));
tvActorContent.setText(StringFormatUtil.formatName(data.getCasts(), true));
tvTypeContent.setText(StringFormatUtil.formatGenres(data.getGenres()));
tvScoreContent.setText(String.valueOf(data.getRating().getAverage()));
//动画
itemView.setScaleX(0.8f);
itemView.setScaleY(0.8f);
itemView.animate().scaleX(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
itemView.animate().scaleY(1).setDuration(350).setInterpolator(new OvershootInterpolator()).start();
//
itemView.setOnClickListener(view -> MovieDetailsActivity.startAction((Activity) getContext(), data, ivRanking));
}
@Override
public void startAnimation(final DynamicWeatherView dynamicWeatherView, int fromColor) {
super.startAnimation(dynamicWeatherView, fromColor);
ValueAnimator animator1 = ValueAnimator.ofFloat(0, 1);
animator1.setInterpolator(new OvershootInterpolator());
animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
speed = (float) animation.getAnimatedValue() * 32;
rotate = (float) animation.getAnimatedValue();
}
});
AnimatorSet animSet = new AnimatorSet();
animSet.play(animator1);
animSet.setDuration(1000);
animSet.start();
}
@Override
public void startAnimation(DynamicWeatherView dynamicWeatherView, int fromColor) {
super.startAnimation(dynamicWeatherView, fromColor);
ValueAnimator animator = ValueAnimator.ofFloat(-bitmap.getWidth() * 0.25f, getWidth() - bitmap.getWidth() * 0.25f);
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new OvershootInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transFactor = (float) animation.getAnimatedValue();
}
});
animator.start();
}
@Override
public void startAnimation(DynamicWeatherView dynamicWeatherView, int fromColor) {
super.startAnimation(dynamicWeatherView, fromColor);
ValueAnimator animator = ValueAnimator.ofFloat(-bitmap.getWidth() * 0.25f, getWidth() - bitmap.getWidth() * 0.25f);
animator.setDuration(1000);
animator.setRepeatCount(0);
animator.setInterpolator(new OvershootInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
transFactor = (float) animation.getAnimatedValue();
}
});
animator.start();
}
@Override
public void startAnimation(final DynamicWeatherView dynamicWeatherView, int fromColor) {
super.startAnimation(dynamicWeatherView, fromColor);
ValueAnimator animator1 = ValueAnimator.ofFloat(0, 1);
animator1.setInterpolator(new OvershootInterpolator());
animator1.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
speed = (float) animation.getAnimatedValue() * 32;
rotate = (float) animation.getAnimatedValue();
}
});
AnimatorSet animSet = new AnimatorSet();
animSet.play(animator1);
animSet.setDuration(1000);
animSet.start();
}
@Override
public void onExpansionToggled(boolean expanded) {
super.onExpansionToggled(expanded);
ObjectAnimator imageViewObjectAnimator;
if (expanded) { // rotate clockwise
imageViewObjectAnimator = ObjectAnimator.ofFloat(mArrowExpandImageView ,
View.ROTATION, ROTATED_POSITION,INITIAL_POSITION);
} else { // rotate counterclockwise
imageViewObjectAnimator = ObjectAnimator.ofFloat(mArrowExpandImageView ,
View.ROTATION,INITIAL_POSITION, ROTATED_POSITION);
}
imageViewObjectAnimator.setDuration(1000);
imageViewObjectAnimator.setInterpolator(new OvershootInterpolator());
imageViewObjectAnimator.start();
}
private void addScaleAnimation(int startDelay, int duration, AnimatorSet set) {
final int start = !isFolded ? 1 : 0;
final int end = ~start & 0x1;
AnimatorSet buttonSet = new AnimatorSet();
for (int index = 0; index < dots.size(); index++) {
FloatingActionButton tempDot = dots.get(index);
if (tempDot.getId() != lastDot.getId()) {
ObjectAnimator scaleX = ObjectAnimator.ofFloat(tempDot, View.SCALE_X, start, end);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(tempDot, View.SCALE_Y, start, end);
ObjectAnimator fade = ObjectAnimator.ofFloat(tempDot, View.ALPHA, start, end);
scaleX.setStartDelay(startDelay);
scaleY.setStartDelay(startDelay);
scaleX.setInterpolator(new OvershootInterpolator(2));
scaleY.setInterpolator(new OvershootInterpolator(2));
fade.setStartDelay(startDelay);
buttonSet.playTogether(scaleX, scaleY, fade);
}
}
buttonSet.setDuration(duration);
set.playTogether(buttonSet);
}
private AnimationSet startShowContinueIconAnimations() {
Animation mScaleAnimation = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Animation mRotateAnimation = new RotateAnimation(
0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
mRotateAnimation.setRepeatCount(0);
AnimationSet mAnimations = new AnimationSet(true);
mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
mAnimations.setFillAfter(true);
mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
mAnimations.addAnimation(mScaleAnimation);
mAnimations.addAnimation(mRotateAnimation);
mContinueIcon.startAnimation(mAnimations);
return mAnimations;
}
private AnimationSet startHideContinueIconAnimations() {
Animation mScaleAnimation = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
Animation mRotateAnimation = new RotateAnimation(
0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
);
mRotateAnimation.setRepeatCount(0);
AnimationSet mAnimations = new AnimationSet(true);
mAnimations.setDuration(REVEAL_ANIMATION_DURATION);
mAnimations.setFillAfter(true);
mAnimations.setInterpolator(new OvershootInterpolator(1.5f));
mAnimations.addAnimation(mScaleAnimation);
mAnimations.addAnimation(mRotateAnimation);
mContinueIcon.startAnimation(mAnimations);
return mAnimations;
}
@Override
public void showTitle(String title) {
playlistTitle.setText(title);
playlistTitle.setScaleX(0);
playlistTitle.setScaleY(0);
titleBackground.post(() -> {
int cx = titleBackground.getWidth() / 2;
int cy = titleBackground.getHeight() / 2;
Animator animator = ViewAnimationUtils.createCircularReveal(titleBackground, cx, cy, 0,
(int) Math.hypot(titleBackground.getWidth(), titleBackground.getHeight()));
animator.setDuration(400);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
titleBackground.setVisibility(View.VISIBLE);
playlistTitle.animate()
.setDuration(400)
.scaleX(1).scaleY(1)
.setInterpolator(new OvershootInterpolator())
.start();
}
});
animator.start();
});
}
public void showPlayButton() {
playOverlay.setVisibility(VISIBLE);
playOverlay.animate()
.setListener(null)
.alpha(1)
.scaleX(1).scaleY(1)
.setInterpolator(new OvershootInterpolator())
.start();
}
@MainThread
public void append(int value) {
if (index >= codes.size()) return;
setInactive(containers);
setActive(containers.get(index));
TextView codeView = codes.get(index++);
Animation translateIn = new TranslateAnimation(0, 0, codeView.getHeight(), 0);
translateIn.setInterpolator(new OvershootInterpolator());
translateIn.setDuration(500);
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setDuration(200);
AnimationSet animationSet = new AnimationSet(false);
animationSet.addAnimation(fadeIn);
animationSet.addAnimation(translateIn);
animationSet.reset();
animationSet.setStartTime(0);
codeView.setText(String.valueOf(value));
codeView.clearAnimation();
codeView.startAnimation(animationSet);
if (index == codes.size() && listener != null) {
listener.onCodeComplete(Stream.of(codes).map(TextView::getText).collect(Collectors.joining()));
}
}
private void initUi() {
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
toolbar.setNavigationOnClickListener(v -> onBackPressed());
mRecyclerView.setHasFixedSize(true);
mRecyclerView.setAdapter((adapter = new ItemsAdapter()));
mRecyclerView.setLayoutManager(new GridLayoutManager(getApplicationContext(), 1));
mRecyclerView.setItemAnimator(
AnimationUtils.getItemAnimator(
new LandingAnimator(new OvershootInterpolator(1f))
));
}
/**
* コンストラクタ
*/
AnimationHandler(TrashView trashView) {
mTrashView = new WeakReference<>(trashView);
mStartedCode = ANIMATION_NONE;
mTrashIconLimitPosition = new Rect();
mOvershootInterpolator = new OvershootInterpolator(OVERSHOOT_TENSION);
}
private void setupLayout() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
mPieChart.setTextFormatter(progress -> {
int voters = (int) (progress * maxVoters / 100);
if(voters > 1000) {
voters /= 1000;
return voters + " k voters";
}
return voters + " Voters";
});
mFillChart.setTextFormatter(progress -> {
int cals = (int) (progress * maxCalories / 100);
return cals + " cal";
});
SpannableStringBuilder b = new SpannableStringBuilder();
mRingChart.setTextFormatter(progress -> {
int days = (int) (progress * maxDays / 100);
// b.clear();
// String text =;
// b.append(text);
// int start = String.valueOf(days).length();
// int end = b.length();
// b.setSpan(new RelativeSizeSpan(0.4f), 0, start, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// mText.setText(b);
return days + " days";
});
}
private void setupLayoutAnimation() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
displayedMode = MODE_PIE;
mConstraintSet = new ConstraintSet();
mConstraintSet.clone(mConstraintLayout);
fade = new Fade();
fade.setDuration(400);
}
private void setupLayoutAnimation() {
Explode transition = new Explode();
transition.setDuration(600);
transition.setInterpolator(new OvershootInterpolator(1f));
getWindow().setEnterTransition(transition);
displayedMode = MODE_PIE;
mConstraintSet = new ConstraintSet();
mConstraintSet.clone(mConstraintLayout);
fade = new Fade();
fade.setDuration(400);
}