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


Java ViewPropertyAnimator.translationY方法代码示例

本文整理汇总了Java中android.view.ViewPropertyAnimator.translationY方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPropertyAnimator.translationY方法的具体用法?Java ViewPropertyAnimator.translationY怎么用?Java ViewPropertyAnimator.translationY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ViewPropertyAnimator的用法示例。


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

示例1: startAnimators

import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
    if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
        view.clearAnimation();
        view.animate().cancel();
        final Resources res = view.getResources();
        final float endAlpha = view.getAlpha();
        final float endTranslateX = view.getTranslationX();
        final float endTranslateY = view.getTranslationY();
        view.setAlpha(0);
        final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
        fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setStartDelay(delay);
        fade.start();
        ViewPropertyAnimator slide = view.animate();
        if (startOffsetY != 0) {
            view.setTranslationY(startOffsetY);
            slide.translationY(endTranslateY);
        } else {
            view.setTranslationX(startOffsetX);
            slide.translationX(endTranslateX);
        }
        slide.setInterpolator(new DecelerateInterpolator(2));
        slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
        slide.setStartDelay(delay);
        slide.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                if (fade.isStarted()) {
                    fade.cancel();
                }
                view.setAlpha(endAlpha);
                view.setTranslationX(endTranslateX);
                view.setTranslationY(endTranslateY);
            }
        });
        slide.start();
    }
}
 
开发者ID:rumaan,项目名称:file.io-app,代码行数:40,代码来源:MaterialIn.java

示例2: translationY

import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
public ViewPropertyAnimator translationY(float value) {
    ViewPropertyAnimator n = (ViewPropertyAnimator) this.mNative.get();
    if (n != null) {
        n.translationY(value);
    }
    return this;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:ViewPropertyAnimatorICS.java

示例3: animateShow

import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
public void animateShow() {
  // This is a hack; without this, the setTranslationY is delayed in being applied, and the
  // numbers appear at their original position (0) momentarily before animating.
  final AnimatorListenerAdapter showListener = new AnimatorListenerAdapter() {};

  for (int i = 0; i < mButtonIds.length; i++) {
    int delay = (int) (getKeyButtonAnimationDelay(mButtonIds[i]) * DELAY_MULTIPLIER);
    int duration = (int) (getKeyButtonAnimationDuration(mButtonIds[i]) * DURATION_MULTIPLIER);
    final DialpadKeyButton dialpadKey = (DialpadKeyButton) findViewById(mButtonIds[i]);

    ViewPropertyAnimator animator = dialpadKey.animate();
    if (mIsLandscape) {
      // Landscape orientation requires translation along the X axis.
      // For RTL locales, ensure we translate negative on the X axis.
      dialpadKey.setTranslationX((mIsRtl ? -1 : 1) * mTranslateDistance);
      animator.translationX(0);
    } else {
      // Portrait orientation requires translation along the Y axis.
      dialpadKey.setTranslationY(mTranslateDistance);
      animator.translationY(0);
    }
    animator
        .setInterpolator(AnimUtils.EASE_OUT_EASE_IN)
        .setStartDelay(delay)
        .setDuration(duration)
        .setListener(showListener)
        .start();
  }
}
 
开发者ID:dialogs,项目名称:android-dialer,代码行数:30,代码来源:DialpadView.java

示例4: openMenu

import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
 * Open menu
 */
@SuppressWarnings("unused")
public void openMenu() {
    if (isOpened) {
        return;
    }
    fabMain.setSelected(true);
    fabMain.animate().rotation(fabRotationAngle)
            .setDuration(MAIN_FAB_ROTATE_DURATION)
            .start();

    for (int i = 0; i < menuContainer.getChildCount(); i++) {
        View itemView = menuContainer.getChildAt(i);

        itemView.setAlpha(0.0f);

        ViewPropertyAnimator animator = itemView.animate();
        if (isLandscapeLayout) {
            itemView.setTranslationX(MINI_FAB_SHOW_TRANSLATION);
            animator.translationX(0.0f);
        } else {
            itemView.setTranslationY(MINI_FAB_SHOW_TRANSLATION);
            animator.translationY(0.0f);
        }
        animator.alpha(1.0f)
                .setDuration(MINI_FAB_SHOW_DURATION)
                .setStartDelay((menu.size() - 1 - i) * MINI_FAB_SHOW_DELAY)
                .start();
    }

    menuContainer.setVisibility(View.VISIBLE);
    if (useTouchGuard) {
        touchGuard.setVisibility(View.VISIBLE);
        if (useRevealEffect) {
            touchGuard.setAlpha(0.0f);
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    touchGuard.setAlpha(1.0f);
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        int cx = fabsContainer.getLeft() + (fabMain.getLeft() + fabMain.getRight()) / 2;
                        int cy = fabsContainer.getTop() + (fabMain.getTop() + fabMain.getBottom()) / 2;
                        float radius = Math.max(touchGuard.getWidth(), touchGuard.getHeight()) * 2.0f;
                        ViewAnimationUtils.createCircularReveal(touchGuard, cx, cy, 0, radius).start();
                    }
                }
            });
        }
    }
    isOpened = true;
    for (OnStateChangeListener listener : stateChangeListeners) {
        listener.onStateChange(isOpened);
    }
}
 
开发者ID:kobakei,项目名称:MaterialFabSpeedDial,代码行数:57,代码来源:FabSpeedDial.java

示例5: doSwipe

import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
 *
 * @param isSwipeIn
 */
protected void doSwipe(boolean isSwipeIn){
    if(mLayoutView != null && mViewRemoveAnimatorListener != null && !mSwipeOption.getIsViewLocked()) {
        if(!mSwipeOption.getIsPutBackActive()) {
          blockTouch();
        }

        if (isSwipeIn) {
            if (getSwipeInMsgView() != null) {
                getSwipeInMsgView().setVisibility(VISIBLE);
            }
        } else {
            if (getSwipeOutMsgView() != null) {
                getSwipeOutMsgView().setVisibility(VISIBLE);
            }
        }

        DisplayMetrics displayMetrics = mLayoutView.getResources().getDisplayMetrics();
        ViewPropertyAnimator animator = mLayoutView.animate();

        float transX = displayMetrics.widthPixels;
        float transY = displayMetrics.heightPixels;
        switch (mSwipeType){
            case SwipePlaceHolderView.SWIPE_TYPE_DEFAULT:
                if(isSwipeIn){
                    bindSwipeIn(getResolver());
                    animator.rotation(-mSwipeDecor.getSwipeRotationAngle());
                }else{
                    bindSwipeOut(getResolver());
                    transX = -mLayoutView.getWidth();
                    animator.rotation(mSwipeDecor.getSwipeRotationAngle());
                }
                animator.translationX(transX).translationY(transY);
                break;
            case SwipePlaceHolderView.SWIPE_TYPE_HORIZONTAL:
                if(isSwipeIn){
                    bindSwipeIn(getResolver());
                }else{
                    bindSwipeOut(getResolver());
                    transX = -mLayoutView.getWidth();
                }
                animator.translationX(transX);
                break;
            case SwipePlaceHolderView.SWIPE_TYPE_VERTICAL:
                if(isSwipeIn){
                    bindSwipeIn(getResolver());
                }else{
                    bindSwipeOut(getResolver());
                    transY = -mLayoutView.getHeight();
                }
                animator.translationY(transY);
                break;
        }

        animator.setDuration((long) (mSwipeDecor.getSwipeAnimTime() * 1.25))
                .setInterpolator(new AccelerateInterpolator(mSwipeDecor.getSwipeAnimFactor()))
                .setListener(mViewRemoveAnimatorListener)
                .start();
    }
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:64,代码来源:SwipeViewBinder.java


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