本文整理汇总了Java中android.view.animation.DecelerateInterpolator类的典型用法代码示例。如果您正苦于以下问题:Java DecelerateInterpolator类的具体用法?Java DecelerateInterpolator怎么用?Java DecelerateInterpolator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DecelerateInterpolator类属于android.view.animation包,在下文中一共展示了DecelerateInterpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHideItemAnimator
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
private Animator createHideItemAnimator(final View item) {
final float dx = centerItem.getX() - item.getX();
final float dy = centerItem.getY() - item.getY();
Animator anim = ObjectAnimator.ofPropertyValuesHolder(
item,
AnimatorUtils.scaleX(1f, 0f),
AnimatorUtils.scaleY(1f, 0f),
AnimatorUtils.translationX(0f, dx),
AnimatorUtils.translationY(0f, dy)
);
anim.setInterpolator(new DecelerateInterpolator());
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
item.setTranslationX(0f);
item.setTranslationY(0f);
}
});
anim.setDuration(50);
return anim;
}
示例2: showBouceAnimation
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
public void showBouceAnimation() {
playPauseFab.clearAnimation();
playPauseFab.setScaleX(0.9f);
playPauseFab.setScaleY(0.9f);
playPauseFab.setVisibility(View.VISIBLE);
playPauseFab.setPivotX(playPauseFab.getWidth() / 2);
playPauseFab.setPivotY(playPauseFab.getHeight() / 2);
playPauseFab.animate()
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.scaleX(1.1f)
.scaleY(1.1f)
.withEndAction(() -> playPauseFab.animate()
.setDuration(200)
.setInterpolator(new AccelerateInterpolator())
.scaleX(1f)
.scaleY(1f)
.alpha(1f)
.start())
.start();
}
示例3: showHeartAnimation
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
public void showHeartAnimation() {
shuffleButton.clearAnimation();
shuffleButton.setScaleX(0.9f);
shuffleButton.setScaleY(0.9f);
shuffleButton.setVisibility(View.VISIBLE);
shuffleButton.setPivotX(shuffleButton.getWidth() / 2);
shuffleButton.setPivotY(shuffleButton.getHeight() / 2);
shuffleButton.animate()
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.scaleX(1.1f)
.scaleY(1.1f)
.withEndAction(() -> shuffleButton.animate()
.setDuration(200)
.setInterpolator(new AccelerateInterpolator())
.scaleX(1f)
.scaleY(1f)
.alpha(1f)
.start())
.start();
}
示例4: toggleToolbar
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
public void toggleToolbar(boolean show) {
if (show==showToolbar || toolbarGroup==null) {
return;
}
showToolbar=show;
if (showToolbar) {
startTimeOut();
showSystemUI();
toolbarGroup.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
} else {
if (timeoutSubscription!=null) {
timeoutSubscription.unsubscribe();
}
toolbarGroup.animate().translationY(-toolbarGroup.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
hideSystemUI();
}
}
示例5: completeAnimationImmediately
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
@Thunk void completeAnimationImmediately() {
if (a != null) {
a.cancel();
}
setInitialAnimationValues(true);
a = LauncherAnimUtils.ofPropertyValuesHolder(child,
new PropertyListBuilder()
.scale(initScale)
.translationX(initDeltaX)
.translationY(initDeltaY)
.build())
.setDuration(REORDER_ANIMATION_DURATION);
a.setInterpolator(new android.view.animation.DecelerateInterpolator(1.5f));
a.start();
}
示例6: toggle
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
private void toggle() {
if (animator != null) {
animator.cancel();
}
animator = ObjectAnimator.ofFloat(this, PROGRESS, isPlay ? 1.0F : 0.0F, isPlay ? 0.0F : 1.0F);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
isPlay = !isPlay;
}
});
animator.setInterpolator(new DecelerateInterpolator());
animator.setDuration(200);
animator.start();
}
示例7: showInstructionList
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
/**
* Show the instruction list and hide the sound button.
* <p>
* This is based on orientation so the different layouts (for portrait vs. landscape)
* can be animated appropriately.
*/
public void showInstructionList() {
int orientation = getContext().getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
ConstraintSet expanded = new ConstraintSet();
expanded.clone(getContext(), R.layout.instruction_layout_alt);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
TransitionManager.beginDelayedTransition(InstructionView.this);
}
expanded.applyTo(instructionLayout);
instructionListLayout.setVisibility(VISIBLE);
} else {
Animation slideDown = AnimationUtils.loadAnimation(getContext(), R.anim.slide_down_top);
slideDown.setInterpolator(new DecelerateInterpolator());
instructionListLayout.setVisibility(VISIBLE);
instructionListLayout.startAnimation(slideDown);
}
}
示例8: initAnimations
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
/**
* Initializes all animations needed to show / hide views.
*/
private void initAnimations() {
Context context = getContext();
rerouteSlideDownTop = AnimationUtils.loadAnimation(context, R.anim.slide_down_top);
rerouteSlideUpTop = AnimationUtils.loadAnimation(context, R.anim.slide_up_top);
Animation fadeIn = new AlphaAnimation(0, 1);
fadeIn.setInterpolator(new DecelerateInterpolator());
fadeIn.setDuration(300);
Animation fadeOut = new AlphaAnimation(1, 0);
fadeOut.setInterpolator(new AccelerateInterpolator());
fadeOut.setStartOffset(1000);
fadeOut.setDuration(1000);
fadeInSlowOut = new AnimationSet(false);
fadeInSlowOut.addAnimation(fadeIn);
fadeInSlowOut.addAnimation(fadeOut);
}
示例9: onFling
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mode == DRAG) {
if (flingDuration > 0 && !isAnimating()) {
float factor = ((float) flingDuration / 1000f) * flingExaggeration;
float[] values = corrector.getValues();
float dx = (velocityX * factor) * values[Matrix.MSCALE_X];
float dy = (velocityY * factor) * values[Matrix.MSCALE_Y];
PropertyValuesHolder flingX = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_X, values[Matrix.MTRANS_X], values[Matrix.MTRANS_X] + dx);
PropertyValuesHolder flingY = PropertyValuesHolder.ofFloat(FlingAnimatorHandler.PROPERTY_TRANSLATE_Y, values[Matrix.MTRANS_Y], values[Matrix.MTRANS_Y] + dy);
valueAnimator = ValueAnimator.ofPropertyValuesHolder(flingX, flingY);
valueAnimator.setDuration(flingDuration);
valueAnimator.addUpdateListener(new FlingAnimatorHandler(corrector));
valueAnimator.setInterpolator(new DecelerateInterpolator());
valueAnimator.start();
return true;
}
}
return super.onFling(e1, e2, velocityX, velocityY);
}
示例10: LingjuSwipeRefreshLayout
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
/**
* Constructor that is called when inflating SwipeRefreshLayout from XML.
*
* @param context
* @param attrs
*/
public LingjuSwipeRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMediumAnimationDuration = getResources().getInteger(
android.R.integer.config_mediumAnimTime);
setWillNotDraw(false);
mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
setEnabled(a.getBoolean(0, true));
a.recycle();
final DisplayMetrics metrics = getResources().getDisplayMetrics();
mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);
createProgressView();
ViewCompat.setChildrenDrawingOrderEnabled(this, true);
// the absolute offset has to take into account that the circle starts at an offset
mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
mTotalDragDistance = mSpinnerFinalOffset;
}
示例11: LingjuSwipeUpLoadRefreshLayout
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
/**
* Constructor that is called when inflating SwipeRefreshLayout from XML.
*
* @param context
* @param attrs
*/
public LingjuSwipeUpLoadRefreshLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
mMediumAnimationDuration = getResources().getInteger(
android.R.integer.config_mediumAnimTime);
setWillNotDraw(false);
mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
setEnabled(a.getBoolean(0, true));
a.recycle();
final DisplayMetrics metrics = getResources().getDisplayMetrics();
mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density);
mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density);
createProgressView();
ViewCompat.setChildrenDrawingOrderEnabled(this, true);
// the absolute offset has to take into account that the circle starts at an offset
mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
mTotalDragDistance = mSpinnerFinalOffset;
}
示例12: createAnimatorToHeadView
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
public void createAnimatorToHeadView(final View v, final float angle)
{
ViewPropertyAnimatorCompat viewPropertyAnimatorCompat = ViewCompat.animate(v);
viewPropertyAnimatorCompat.setDuration(200);
viewPropertyAnimatorCompat.setInterpolator(new DecelerateInterpolator());
viewPropertyAnimatorCompat.rotationX(90);
viewPropertyAnimatorCompat.start();
viewPropertyAnimatorCompat.setUpdateListener(new ViewPropertyAnimatorUpdateListener() {
@Override
public void onAnimationUpdate(View view) {
float height = ViewCompat.getTranslationY(mChildView);
mHeadLayout.setPivotX(mHeadLayout.getWidth() / 2);
mHeadLayout.setPivotY(height);
}
});
}
示例13: onMapClick
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
/**
* 点击map,隐藏/显示Map上的元素
* @param latLng
*/
@Override
public void onMapClick(LatLng latLng) {
SearchView search_view = (SearchView) ((Activity)mContext).findViewById(R.id.search_view);
MapToolsView map_tool = (MapToolsView) ((Activity)mContext).findViewById(R.id.map_tool);
DisplayMetrics metrics = new DisplayMetrics();
((Activity)mContext).getWindowManager().getDefaultDisplay().getMetrics(metrics);
if (mIsMapElementsShow) {
mIsMapElementsShow = false;
search_view.animate().translationY((search_view.getHeight() + dp2px(mContext, 6)) * (-1)).setInterpolator(new DecelerateInterpolator());
map_tool.animate().translationY(map_tool.getHeight() + dp2px(mContext, 6)).setInterpolator(new DecelerateInterpolator());
} else {
mIsMapElementsShow = true;
search_view.animate().translationY(0).setInterpolator(new DecelerateInterpolator());
map_tool.animate().translationY(0).setInterpolator(new DecelerateInterpolator());
}
}
示例14: enter
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
public static Completable enter(final View view, final int xOffset, final int yOffset) {
final float startingX = view.getX();
final float startingY = view.getY();
return animate(view, new DecelerateInterpolator())
.fadeIn()
.translateBy(xOffset, yOffset)
.onAnimationCancel(aView -> set(aView, startingX, startingY, OPAQUE))
.schedule();
}
示例15: smoothScrollTo
import android.view.animation.DecelerateInterpolator; //导入依赖的package包/类
private final void smoothScrollTo(int newScrollValue, long duration, long delayMillis, OnSmoothScrollFinishedListener listener) {
int oldScrollValue;
if (this.mCurrentSmoothScrollRunnable != null) {
this.mCurrentSmoothScrollRunnable.stop();
}
switch (getPullToRefreshScrollDirection()) {
case HORIZONTAL:
oldScrollValue = getScrollX();
break;
default:
oldScrollValue = getScrollY();
break;
}
if (oldScrollValue != newScrollValue) {
if (this.mScrollAnimationInterpolator == null) {
this.mScrollAnimationInterpolator = new DecelerateInterpolator();
}
this.mCurrentSmoothScrollRunnable = new SmoothScrollRunnable(oldScrollValue, newScrollValue, duration, listener);
if (delayMillis > 0) {
postDelayed(this.mCurrentSmoothScrollRunnable, delayMillis);
} else {
post(this.mCurrentSmoothScrollRunnable);
}
}
}