当前位置: 首页>>代码示例>>Java>>正文


Java Interpolator类代码示例

本文整理汇总了Java中android.view.animation.Interpolator的典型用法代码示例。如果您正苦于以下问题:Java Interpolator类的具体用法?Java Interpolator怎么用?Java Interpolator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Interpolator类属于android.view.animation包,在下文中一共展示了Interpolator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: animatePeek

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Starts a peek animation to add a specific tab.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be added, as an instance of the
 *         class {@link AbstractItem}. The item may not be null
 * @param duration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param interpolator
 *         The interpolator, which should be used by the animation, as an instance of the type
 *         {@link Interpolator}. The interpolator may not be null
 * @param peekPosition
 *         The position on the dragging axis, the tab should be moved to, in pixels as a {@link
 *         Float} value
 * @param peekAnimation
 *         The peek animation, which has been used to add the tab, as an instance of the class
 *         {@link PeekAnimation}. The peek animation may not be null
 */
private void animatePeek(@NonNull final AbstractItem item, final long duration,
                         @NonNull final Interpolator interpolator, final float peekPosition,
                         @NonNull final PeekAnimation peekAnimation) {
    PhoneTabViewHolder viewHolder = (PhoneTabViewHolder) ((TabItem) item).getViewHolder();
    viewHolder.closeButton.setVisibility(View.GONE);
    View view = item.getView();
    float x = peekAnimation.getX();
    float y = peekAnimation.getY() + tabTitleContainerHeight;
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setAlpha(1f);
    getArithmetics().setPivot(Axis.X_AXIS, item, x);
    getArithmetics().setPivot(Axis.Y_AXIS, item, y);
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 0);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(interpolator);
    animation.setListener(
            new AnimationListenerWrapper(createPeekAnimationListener(item, peekAnimation)));
    animation.setStartDelay(0);
    animation.setDuration(duration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, item, peekPosition, true);
    animation.start();
    int selectedTabIndex = getModel().getSelectedTabIndex();
    TabItem selectedItem = TabItem.create(getModel(), tabViewRecycler, selectedTabIndex);
    tabViewRecycler.inflate(selectedItem);
    selectedItem.getTag().setPosition(0);
    PhoneTabViewHolder selectedTabViewHolder =
            (PhoneTabViewHolder) selectedItem.getViewHolder();
    selectedTabViewHolder.closeButton.setVisibility(View.GONE);
    animateShowSwitcher(selectedItem, duration, interpolator,
            createZoomOutAnimationListener(selectedItem, peekAnimation));
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:55,代码来源:PhoneTabSwitcherLayout.java

示例2: createPeekLayoutListener

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Creates and returns a layout listener, which allows to start a peek animation to add a tab,
 * once its view has been inflated.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, which should be added, as an instance of
 *         the class {@link TabItem}. The tab item may not be null
 * @param peekAnimation
 *         The peek animation, which should be started, as an instance of the class {@link
 *         PeekAnimation}. The peek animation may not be null
 * @return The listener, which has been created, as an instance of the type {@link
 * OnGlobalLayoutListener}. The listener may not be null
 */
private OnGlobalLayoutListener createPeekLayoutListener(@NonNull final TabItem tabItem,
                                                        @NonNull final PeekAnimation peekAnimation) {
    return new OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            long totalDuration =
                    peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() :
                            peekAnimationDuration;
            long duration = totalDuration / 3;
            Interpolator interpolator =
                    peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() :
                            new AccelerateDecelerateInterpolator();
            float peekPosition =
                    getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false) * 0.66f;
            animatePeek(tabItem, duration, interpolator, peekPosition, peekAnimation);
        }

    };
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:34,代码来源:PhoneTabSwitcherLayout.java

示例3: initSwitchSpeed

import android.view.animation.Interpolator; //导入依赖的package包/类
private void initSwitchSpeed(float scrollFactor) {
    try {
        Class<?> viewpager = ViewPager.class;
        Field scroller = viewpager.getDeclaredField("mScroller");
        scroller.setAccessible(true);
        Field interpolator = viewpager.getDeclaredField("sInterpolator");
        interpolator.setAccessible(true);

        mScroller = new ScrollerCustomDuration(getContext(),
                (Interpolator) interpolator.get(null));
        mScroller.setScrollFactor(scrollFactor);
        scroller.set(this, mScroller);
    } catch (Exception e) {

    }
}
 
开发者ID:codeestX,项目名称:ECardFlow,代码行数:17,代码来源:ECardFlow.java

示例4: setupSharedEelementTransitions

import android.view.animation.Interpolator; //导入依赖的package包/类
public void setupSharedEelementTransitions() {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
        return; //Show dialog normally if below Lollipop
    ArcMotion arcMotion = new ArcMotion();
    arcMotion.setMinimumHorizontalAngle(50f);
    arcMotion.setMinimumVerticalAngle(50f);

    Interpolator easeInOut = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in);

    MorphFabToDialog sharedEnter = new MorphFabToDialog(getBackgroundColor());
    sharedEnter.setPathMotion(arcMotion);
    sharedEnter.setInterpolator(easeInOut);

    MorphDialogToFab sharedReturn = new MorphDialogToFab(getBackgroundColor());
    sharedReturn.setPathMotion(arcMotion);
    sharedReturn.setInterpolator(easeInOut);

    if (ui.container != null) {
        sharedEnter.addTarget(ui.container);
        sharedReturn.addTarget(ui.container);
    }
    getWindow().setSharedElementEnterTransition(sharedEnter);
    getWindow().setSharedElementReturnTransition(sharedReturn);
}
 
开发者ID:AdityaAnand1,项目名称:Morphing-Material-Dialogs,代码行数:25,代码来源:DialogActivity.java

示例5: postInitViewPager

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Override the Scroller instance with our own class so we can change the
 * duration
 */
private void postInitViewPager() {
  if (isInEditMode()) {
    return;
  }
  try {
    Field scroller = ViewPager.class.getDeclaredField("mScroller");
    scroller.setAccessible(true);
    Field interpolator = ViewPager.class
        .getDeclaredField("sInterpolator");
    interpolator.setAccessible(true);

    mScroller = new WXSmoothScroller(getContext(),
        (Interpolator) interpolator.get(null));
    scroller.set(this, mScroller);
  } catch (Exception e) {
    WXLogUtils.e("[CircleViewPager] postInitViewPager: ", e);
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:23,代码来源:WXCircleViewPager.java

示例6: Scroller

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Create a Scroller with the specified interpolator. If the interpolator is
 * null, the default (viscous) interpolator will be used. Specify whether or
 * not to support progressive "flywheel" behavior in flinging.
 */
public Scroller(Context context, Interpolator interpolator, boolean flywheel) {
    mFinished = true;
    mInterpolator = interpolator;
    mPpi = context.getResources().getDisplayMetrics().density * 160.0f;
    mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction());
    mFlywheel = flywheel;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:13,代码来源:Scroller.java

示例7: animateShowSwitcher

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Animates the position and size of a specific tab in order to show the tab switcher.
 *
 * @param tabItem
 *         The tab item, which should be animated, as an instance of the class {@link TabItem}.
 *         The tab item may not be null
 * @param duration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param interpolator
 *         The interpolator, which should be used by the animation, as an instance of the type
 *         {@link Interpolator}. The interpolator may not be null
 * @param listener
 *         The listener, which should be notified about the animation's progress, as an instance
 *         of the type {@link AnimatorListener} or null, if no listener should be notified
 */
private void animateShowSwitcher(@NonNull final TabItem tabItem, final long duration,
                                 @NonNull final Interpolator interpolator,
                                 @Nullable final AnimatorListener listener) {
    View view = tabItem.getView();
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, view, 1);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, view, 1);
    getArithmetics().setPivot(Axis.DRAGGING_AXIS, view,
            getArithmetics().getPivot(Axis.DRAGGING_AXIS, view, DragState.NONE));
    getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, view,
            getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, view, DragState.NONE));
    float scale = getArithmetics().getScale(view, true);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (tabItem.getIndex() < selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, view,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
    } else if (tabItem.getIndex() > selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, view,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    }

    if (tabViewBottomMargin == -1) {
        tabViewBottomMargin = calculateBottomMargin(view);
    }

    animateBottomMargin(view, tabViewBottomMargin, duration, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale);
    getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animation, view,
            tabItem.getTag().getPosition(), true);
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, view, 0, true);
    animation.setStartDelay(0);
    animation.start();
}
 
开发者ID:NeoTerm,项目名称:NeoTerm,代码行数:58,代码来源:PhoneTabSwitcherLayout.java

示例8: zoom

import android.view.animation.Interpolator; //导入依赖的package包/类
public CanvasTransformer zoom(final int openedX, final int closedX, 
		final int openedY, final int closedY,
		final int px, final int py, final Interpolator interp) {
	initTransformer();
	mTrans = new CanvasTransformer() {
		public void transformCanvas(Canvas canvas, float percentOpen) {
			mTrans.transformCanvas(canvas, percentOpen);
			float f = interp.getInterpolation(percentOpen);
			canvas.scale((openedX - closedX) * f + closedX,
					(openedY - closedY) * f + closedY, px, py);
		}			
	};
	return mTrans;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:15,代码来源:CanvasTransformerBuilder.java

示例9: create

import android.view.animation.Interpolator; //导入依赖的package包/类
public static Interpolator create(Path path) {
    return new PathInterpolator(path);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:4,代码来源:PathInterpolatorCompatApi21.java

示例10: smoothScrollBy

import android.view.animation.Interpolator; //导入依赖的package包/类
public void smoothScrollBy(int dx, int dy, int duration, Interpolator interpolator) {
    if (mInterpolator != interpolator) {
        mInterpolator = interpolator;
        mScroller = ScrollerCompat.create(getContext(), interpolator);
    }
    setScrollState(SCROLL_STATE_SETTLING);
    mLastFlingX = mLastFlingY = 0;
    mScroller.startScroll(0, 0, dx, dy, duration);
    postOnAnimation();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:11,代码来源:RecyclerView.java

示例11: reverse

import android.view.animation.Interpolator; //导入依赖的package包/类
public Morpho reverse(AnimationType type, int duration, Interpolator interpolator) {
    boolean animationPartsIsConfigured = this.animationParts != null && this.animationParts.size() > 0;
    boolean coreViewIsInitialized = this.viewToMorph != null && this.viewDefault != null;
    boolean animationIsNotRunning = this.completeAnimation != null && !this.completeAnimation.isRunning();
    if (animationPartsIsConfigured && coreViewIsInitialized && animationIsNotRunning) {
        this.completeAnimation = new AnimatorSet();
        ArrayList<Animation> reversedAnimationParts = new ArrayList<>();
        reversedAnimationParts.addAll(animationParts);
        Collections.reverse(reversedAnimationParts);
        ArrayList<Animator> animators = new ArrayList<>();
        for (Animation a : reversedAnimationParts) {
            animators.add(a.buildAnimation(this.viewDefault, this.viewToMorph, true));
        }
        // Type of Animation
        if (type == AnimationType.SEQUENTIAL) {
            this.completeAnimation.playSequentially(animators);
        } else {
            this.completeAnimation.playTogether(animators);
        }
        // Duration
        if (duration >= 0) {
            this.completeAnimation.setDuration(duration);
        }
        // Interpolator
        if (interpolator != null) {
            this.completeAnimation.setInterpolator(interpolator);
        }
        this.completeAnimation.start();
        this.completeAnimation = null;
    }
    return this;
}
 
开发者ID:rjsvieira,项目名称:morphos,代码行数:33,代码来源:Morpho.java

示例12: startAnimation

import android.view.animation.Interpolator; //导入依赖的package包/类
public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component,
                                  @NonNull WXAnimationBean animationBean, @Nullable String callback) {
  if(component == null){
    return;
  }
  if (component.getHostView() == null) {
    AnimationHolder holder = new AnimationHolder(animationBean, callback);
    component.postAnimation(holder);
    return;
  }
  try {
    Animator animator = createAnimator(animationBean, component.getHostView(),mWXSDKInstance.getViewPortWidth());
    if (animator != null) {
      Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback);
      if(Build.VERSION.SDK_INT<Build.VERSION_CODES.JELLY_BEAN_MR2) {
        component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null);
      }
      Interpolator interpolator = createTimeInterpolator(animationBean);
      if (animatorCallback != null) {
        animator.addListener(animatorCallback);
      }
      if (interpolator != null) {
        animator.setInterpolator(interpolator);
      }
      animator.setDuration(animationBean.duration);
      animator.start();
    }
  } catch (RuntimeException e) {
    e.printStackTrace();
    WXLogUtils.e("", e);
  }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:33,代码来源:WXAnimationModule.java

示例13: animateShowSwitcher

import android.view.animation.Interpolator; //导入依赖的package包/类
/**
 * Animates the position and size of a specific tab in order to show the tab switcher.
 *
 * @param item
 *         The item, which corresponds to the tab, which should be animated, as an instance of
 *         the class {@link AbstractItem}. The item may not be null
 * @param duration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param interpolator
 *         The interpolator, which should be used by the animation, as an instance of the type
 *         {@link Interpolator}. The interpolator may not be null
 * @param listener
 *         The listener, which should be notified about the animation's progress, as an instance
 *         of the type {@link AnimatorListener} or null, if no listener should be notified
 */
private void animateShowSwitcher(@NonNull final AbstractItem item, final long duration,
                                 @NonNull final Interpolator interpolator,
                                 @Nullable final AnimatorListener listener) {
    View view = item.getView();
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    view.setX(layoutParams.leftMargin);
    view.setY(layoutParams.topMargin);
    getArithmetics().setScale(Axis.DRAGGING_AXIS, item, 1);
    getArithmetics().setScale(Axis.ORTHOGONAL_AXIS, item, 1);
    getArithmetics().setPivot(Axis.DRAGGING_AXIS, item,
            getArithmetics().getPivot(Axis.DRAGGING_AXIS, item, DragState.NONE));
    getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
            getArithmetics().getPivot(Axis.ORTHOGONAL_AXIS, item, DragState.NONE));
    float scale = getArithmetics().getScale(item, true);
    int selectedTabIndex = getModel().getSelectedTabIndex();

    if (item.getIndex() < selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
                getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS));
    } else if (item.getIndex() > selectedTabIndex) {
        getArithmetics().setPosition(Axis.DRAGGING_AXIS, item,
                getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? 0 :
                        layoutParams.topMargin);
    }

    if (tabViewBottomMargin == -1) {
        tabViewBottomMargin = calculateBottomMargin(item);
    }

    animateBottomMargin(view, tabViewBottomMargin, duration, 0);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, scale);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, scale);
    getArithmetics()
            .animatePosition(Axis.DRAGGING_AXIS, animation, item, item.getTag().getPosition(),
                    true);
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item, 0, true);
    animation.setStartDelay(0);
    animation.start();
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:59,代码来源:PhoneTabSwitcherLayout.java

示例14: getFastOutSlowInInterpolator

import android.view.animation.Interpolator; //导入依赖的package包/类
public static Interpolator getFastOutSlowInInterpolator(Context context) {
    if (fastOutSlowIn == null) {
        fastOutSlowIn = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.fast_out_slow_in);
    }
    return fastOutSlowIn;
}
 
开发者ID:haihaio,项目名称:AmenEye,代码行数:8,代码来源:AnimUtils.java

示例15: parse

import android.view.animation.Interpolator; //导入依赖的package包/类
public static Interpolator parse(Integer type, Float cycles) {
        if (type != null) {
            switch (type) {
                case 0:
                    return new AccelerateDecelerateInterpolator();
                case 1:
                    return new AccelerateInterpolator();
                case 2:
                    return new AnticipateInterpolator();
                case 3:
                    return new AnticipateOvershootInterpolator();
                case 4:
                    return new BounceInterpolator();
                case 5:
                    return new CycleInterpolator((cycles != null && cycles > 0) ? cycles : 1f);
                case 6:
                    return new DecelerateInterpolator();
                case 7:
                    return new LinearInterpolator();
                case 8:
                    return new OvershootInterpolator();
                //暂时不支持的
//            case 7: return new FastOutLinearInterplator();
//            case 8: return new FastOutSlowInInterplator();
//            case 10: return new LinearOutSlowInInterplator();
//            case 12: return new PathInterplator();
                default:
                    return new LinearInterpolator();
            }
        } else {
            return new LinearInterpolator();
        }
    }
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:34,代码来源:UDInterpolator.java


注:本文中的android.view.animation.Interpolator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。