本文整理汇总了Java中android.animation.TimeInterpolator类的典型用法代码示例。如果您正苦于以下问题:Java TimeInterpolator类的具体用法?Java TimeInterpolator怎么用?Java TimeInterpolator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeInterpolator类属于android.animation包,在下文中一共展示了TimeInterpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTranslatePlayListAnim
import android.animation.TimeInterpolator; //导入依赖的package包/类
private void startTranslatePlayListAnim(float from, float to, int duration, final View view, @Nullable TimeInterpolator interpolator, @Nullable Animator.AnimatorListener listener) {
final ValueAnimator anim = ObjectAnimator.ofFloat(from, to);
anim.setDuration(duration);
if (interpolator != null)
anim.setInterpolator(interpolator);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float va = (float) animation.getAnimatedValue();
view.setY(va);
}
});
if (listener != null) {
anim.addListener(listener);
}
anim.start();
}
示例2: onAnimationUpdate
import android.animation.TimeInterpolator; //导入依赖的package包/类
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (view.getLayoutParams() != null) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
TimeInterpolator interpolator = animation.getInterpolator();
float fraction = animation.getAnimatedFraction();
if (width != null) {
layoutParams.width = intEvaluator.evaluate(interpolator.getInterpolation(fraction),
width.first,
width.second);
}
if (height != null) {
layoutParams.height = intEvaluator.evaluate(interpolator.getInterpolation(fraction),
height.first,
height.second);
}
view.requestLayout();
}
}
示例3: getTimeInterpolater
import android.animation.TimeInterpolator; //导入依赖的package包/类
private TimeInterpolator getTimeInterpolater() {
switch (mAnimationStyle) {
case ViewBaseCommon.ANIMATION_LINEAR:
return new LinearInterpolator();
case ViewBaseCommon.ANIMATION_DECELERATE:
return new DecelerateInterpolator();
case ViewBaseCommon.ANIMATION_ACCELERATE:
return new AccelerateInterpolator();
case ViewBaseCommon.ANIMATION_ACCELERATEDECELERATE:
return new AccelerateDecelerateInterpolator();
case ViewBaseCommon.ANIMATION_SPRING:
return new SpringInterpolator();
default:
return new LinearInterpolator();
}
}
示例4: prepareAnimators
import android.animation.TimeInterpolator; //导入依赖的package包/类
@Override
public void prepareAnimators(DepthRelativeLayout target, int index, int animationDelay) {
final TimeInterpolator interpolator = new ExpoIn();
final float finalTranslationY = exitConfiguration.getFinalYPercent() * target.getResources().getDisplayMetrics().heightPixels;
final float finalTranslationX = exitConfiguration.getFinalXPercent() * target.getResources().getDisplayMetrics().widthPixels;
final long totalDuration = exitConfiguration.getDuration();
final ObjectAnimator translationY2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, finalTranslationY);
translationY2.setDuration(totalDuration);
//translationY2.setInterpolator(new AccelerateInterpolator());
translationY2.setInterpolator(interpolator);
translationY2.setStartDelay(animationDelay);
attachListener(translationY2);
add(translationY2);
final ObjectAnimator translationX2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, finalTranslationX);
translationX2.setDuration(totalDuration);
translationX2.setInterpolator(interpolator);
translationX2.setStartDelay(animationDelay);
add(translationX2);
}
示例5: preparePartialTransition_setsPartialInterpolator
import android.animation.TimeInterpolator; //导入依赖的package包/类
@Test
public void preparePartialTransition_setsPartialInterpolator() {
//given
final StaggeredAnimationGroup spiedGroup = prepareSpiedGroup();
final TimeInterpolator testInterpolator = new LinearOutSlowInInterpolator();
final Transition spiedTransition = spy(new AutoTransition());
final StaggeredAnimationGroup.PartialTransitionFactory factory =
new StaggeredAnimationGroup.PartialTransitionFactory() {
@Override
public Transition createPartialTransition(boolean show, int viewId, int indexInTransition) {
return spiedTransition;
}
};
spiedGroup.setPartialTransitionFactory(factory);
spiedGroup.setPartialInterpolator(testInterpolator);
//when
spiedGroup.preparePartialTransition(true, 0, 0);
//then
verify(spiedTransition, times(1)).setInterpolator(testInterpolator);
}
示例6: setInterpolator
import android.animation.TimeInterpolator; //导入依赖的package包/类
public T setInterpolator(TimeInterpolator interpolator) {
if(mCurrentCustomInterpolator != null) {
switchInterpolator(interpolator);
} else {
getValueAnimator().setInterpolator(interpolator);
}
return self();
}
示例7: setTimeInterpolator
import android.animation.TimeInterpolator; //导入依赖的package包/类
/**
* Set TimeInterpolator for all page animations.
*
* @param interpolator TimeInterpolator
*/
public void setTimeInterpolator(TimeInterpolator interpolator) {
if (pageAnimations == null) return;
for (ArrayList<PageAnimation> pageAnimationsInSamePage : pageAnimations) {
if (pageAnimationsInSamePage == null) continue;
for (PageAnimation pageAnimation : pageAnimationsInSamePage) pageAnimation.setTimeInterpolator(interpolator);
}
}
示例8: runExitAnimation
import android.animation.TimeInterpolator; //导入依赖的package包/类
private static void runExitAnimation(final Activity activity,
ArrayList<EasyTransitionOptions.ViewAttrs> attrs,
long duration,
TimeInterpolator interpolator) {
if (null == attrs || attrs.size() == 0)
return;
for (final EasyTransitionOptions.ViewAttrs attr : attrs) {
View view = activity.findViewById(attr.id);
int[] location = new int[2];
view.getLocationOnScreen(location);
view.setPivotX(0);
view.setPivotY(0);
view.animate()
.scaleX(attr.width / view.getWidth())
.scaleY(attr.height / view.getHeight())
.translationX(attr.startX - location[0])
.translationY(attr.startY - location[1])
.setInterpolator(interpolator)
.setDuration(duration);
}
activity.findViewById(attrs.get(0).id).postDelayed(new Runnable() {
@Override
public void run() {
activity.finish();
activity.overridePendingTransition(0, 0);
}
}, duration);
}
示例9: snapToPage
import android.animation.TimeInterpolator; //导入依赖的package包/类
protected void snapToPage(int whichPage, int duration, boolean immediate,
TimeInterpolator interpolator) {
whichPage = validateNewPage(whichPage);
int newX = getScrollForPage(whichPage);
final int delta = newX - getUnboundedScrollX();
snapToPage(whichPage, delta, duration, immediate, interpolator);
}
示例10: snapToPage
import android.animation.TimeInterpolator; //导入依赖的package包/类
protected void snapToPage(int whichPage, int delta, int duration, boolean immediate,
TimeInterpolator interpolator) {
whichPage = validateNewPage(whichPage);
mNextPage = whichPage;
pageBeginMoving();
awakenScrollBars(duration);
if (immediate) {
duration = 0;
} else if (duration == 0) {
duration = Math.abs(delta);
}
if (!mScroller.isFinished()) {
abortScrollerAnimation(false);
}
if (interpolator != null) {
mScroller.setInterpolator(interpolator);
} else {
mScroller.setInterpolator(mDefaultInterpolator);
}
mScroller.startScroll(getUnboundedScrollX(), 0, delta, 0, duration);
updatePageIndicator();
// Trigger a compute() to finish switching pages if necessary
if (immediate) {
computeScroll();
}
mForceScreenScrolled = true;
invalidate();
}
示例11: hideTargets
import android.animation.TimeInterpolator; //导入依赖的package包/类
private void hideTargets(boolean animate, boolean expanded) {
mTargetAnimations.cancel();
// Note: these animations should complete at the same time so that we can swap out
// the target assets asynchronously from the setTargetResources() call.
mAnimatingTargets = animate;
final int duration = animate ? HIDE_ANIMATION_DURATION : 0;
final int delay = animate ? HIDE_ANIMATION_DELAY : 0;
final float targetScale = expanded ?
TARGET_SCALE_EXPANDED : TARGET_SCALE_COLLAPSED;
final int length = mTargetDrawables.size();
final TimeInterpolator interpolator = Ease.Cubic.easeOut;
for (int i = 0; i < length; i++) {
TargetDrawable target = mTargetDrawables.get(i);
target.setState(TargetDrawable.STATE_INACTIVE);
mTargetAnimations.add(Tweener.to(target, duration,
"ease", interpolator,
"alpha", 0.0f,
"scaleX", targetScale,
"scaleY", targetScale,
"delay", delay,
"onUpdate", mUpdateListener));
}
float ringScaleTarget = expanded ?
RING_SCALE_EXPANDED : RING_SCALE_COLLAPSED;
ringScaleTarget *= mRingScaleFactor;
mTargetAnimations.add(Tweener.to(mOuterRing, duration,
"ease", interpolator,
"alpha", 0.0f,
"scaleX", ringScaleTarget,
"scaleY", ringScaleTarget,
"delay", delay,
"onUpdate", mUpdateListener,
"onComplete", mTargetUpdateListener));
mTargetAnimations.start();
}
示例12: startTranslateYAnim
import android.animation.TimeInterpolator; //导入依赖的package包/类
public static void startTranslateYAnim(float from, float to, int duration, final View view, @Nullable TimeInterpolator interpolator) {
final ValueAnimator anim = ObjectAnimator.ofFloat(from, to);
anim.setDuration(duration);
if (interpolator != null)
anim.setInterpolator(interpolator);
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float va = (float) animation.getAnimatedValue();
view.setY(va);
}
});
anim.start();
}
示例13: toggle
import android.animation.TimeInterpolator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void toggle(final long duration, final @Nullable TimeInterpolator interpolator) {
if (closePosition < getCurrentPosition()) {
collapse(duration, interpolator);
} else {
expand(duration, interpolator);
}
}
示例14: expand
import android.animation.TimeInterpolator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void expand(final long duration, final @Nullable TimeInterpolator interpolator) {
if (isAnimating) return;
if (duration <= 0) {
move(layoutSize, duration, interpolator);
return;
}
createExpandAnimator(getCurrentPosition(), layoutSize, duration, interpolator).start();
}
示例15: collapse
import android.animation.TimeInterpolator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void collapse(final long duration, final @Nullable TimeInterpolator interpolator) {
if (isAnimating) return;
if (duration <= 0) {
move(closePosition, duration, interpolator);
return;
}
createExpandAnimator(getCurrentPosition(), closePosition, duration, interpolator).start();
}