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


Java ViewPropertyAnimator类代码示例

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


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

示例1: animateSwipe

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates a tab to be swiped horizontally.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, which should be swiped, as an instance of
 *         the class {@link TabItem}. The tab item may not be null
 * @param targetPosition
 *         The position on the x-axis, the tab should be moved to, in pixels as a {@link Float}
 *         value
 * @param selected
 *         True, if the tab should become the selected one, false otherwise
 * @param animationDuration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param velocity
 *         The velocity of the drag gesture, which caused the tab to be swiped, in pixels per
 *         second as a {@link Float} value
 */
private void animateSwipe(@NonNull final TabItem tabItem, final float targetPosition,
                          final boolean selected, final long animationDuration,
                          final float velocity) {
    View view = tabItem.getView();
    float currentPosition = getArithmetics().getPosition(Axis.X_AXIS, tabItem);
    float distance = Math.abs(targetPosition - currentPosition);
    float maxDistance = getArithmetics().getSize(Axis.X_AXIS, tabItem) + swipedTabDistance;
    long duration = velocity > 0 ? Math.round((distance / velocity) * 1000) :
            Math.round(animationDuration * (distance / maxDistance));
    ViewPropertyAnimator animation = view.animate();
    animation.setListener(new AnimationListenerWrapper(
            selected ? createSwipeSelectedTabAnimationListener(tabItem) :
                    createSwipeNeighborAnimationListener(tabItem)));
    animation.setInterpolator(new AccelerateDecelerateInterpolator());
    animation.setDuration(duration);
    animation.setStartDelay(0);
    getArithmetics().animatePosition(Axis.X_AXIS, animation, tabItem, targetPosition, true);
    animation.start();
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:37,代码来源:PhoneTabSwitcherLayout.java

示例2: hideProgressBar

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 */
@Override
void hideProgressBar(SearchView searchView) {
	final CircularProgressBar progressBar = searchView.mProgressBar;
	final ViewPropertyAnimator progressBarAnimator = progressBar.animate();
	progressBarAnimator.setListener(null);
	progressBarAnimator.cancel();
	progressBarAnimator
			.alpha(0.0f)
			.setDuration(UiConfig.ANIMATION_DURATION_SHORT)
			.setListener(new AnimatorListenerAdapter() {
				@Override
				public void onAnimationEnd(Animator animation) {
					progressBar.setVisibility(View.INVISIBLE);
				}
			})
			.start();
	final View icon = searchView.mButtonIcon;
	final ViewPropertyAnimator iconAnimator = icon.animate();
	iconAnimator.setListener(null);
	iconAnimator.cancel();
	icon.setVisibility(View.VISIBLE);
	icon.setScaleX(0.5f);
	icon.setScaleY(0.5f);
	icon.setAlpha(0.0f);
	iconAnimator
			.scaleX(1.0f)
			.scaleY(1.0f)
			.alpha(1.0f)
			.setDuration(UiConfig.ANIMATION_DURATION_SHORT)
			.setInterpolator(iconInterpolator)
			.setListener(null)
			.start();
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:36,代码来源:SearchView.java

示例3: listItemUpAnim

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
public static void listItemUpAnim(View view, int position,
                                  AnimatorListenerAdapter animatorListenerAdapter) {
    view.setTranslationY(150);
    view.setAlpha(0.f);
    ViewPropertyAnimator animate = view.animate();
    animate.translationY(0).alpha(1.f)
            .setStartDelay(20 * (position))
            .setInterpolator(new DecelerateInterpolator(2.f))
            .setDuration(400);

    if (animatorListenerAdapter != null) {
        animate.setListener(animatorListenerAdapter);
    }

    animate.withLayer().start();
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:17,代码来源:FeViewUtils.java

示例4: animateReveal

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Starts a reveal 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 revealAnimation
 *         The reveal animation, which should be started, as an instance of the class {@link
 *         RevealAnimation}. The reveal animation may not be null
 */
private void animateReveal(@NonNull final AbstractItem item,
                           @NonNull final RevealAnimation revealAnimation) {
    tabViewBottomMargin = -1;
    tabRecyclerAdapter.clearCachedPreviews();
    dragHandler.setCallback(null);
    View view = item.getView();
    ViewPropertyAnimator animation = view.animate();
    animation.setInterpolator(
            revealAnimation.getInterpolator() != null ? revealAnimation.getInterpolator() :
                    new AccelerateDecelerateInterpolator());
    animation.setListener(new AnimationListenerWrapper(createHideSwitcherAnimationListener()));
    animation.setStartDelay(0);
    animation.setDuration(revealAnimation.getDuration() != -1 ? revealAnimation.getDuration() :
            revealAnimationDuration);
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    animation.start();
    animateToolbarVisibility(getModel().areToolbarsShown() && getModel().isEmpty(), 0);
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:30,代码来源:PhoneTabSwitcherLayout.java

示例5: addFixViewWithAnimator

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
private void addFixViewWithAnimator(LayoutManagerHelper layoutManagerHelper, View fixView) {
    if (mFixViewAnimatorHelper != null) {
        ViewPropertyAnimator animator = mFixViewAnimatorHelper
                .onGetFixViewAppearAnimator(fixView);
        if (animator != null) {
            fixView.setVisibility(View.INVISIBLE);
            layoutManagerHelper.addFixedView(fixView);
            mFixViewAppearAnimatorListener.bindAction(layoutManagerHelper, fixView);
            animator.setListener(mFixViewAppearAnimatorListener).start();
        } else {
            layoutManagerHelper.addFixedView(fixView);
        }
    } else {
        layoutManagerHelper.addFixedView(fixView);
    }
    isRemoveFixViewImmediately = false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:FixLayoutHelper.java

示例6: removeFixViewWithAnimator

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
private void removeFixViewWithAnimator(RecyclerView.Recycler recycler,
        LayoutManagerHelper layoutManagerHelper, View fixView) {
    if (!isRemoveFixViewImmediately && mFixViewAnimatorHelper != null) {
        ViewPropertyAnimator animator = mFixViewAnimatorHelper
                .onGetFixViewDisappearAnimator(fixView);
        if (animator != null) {
            mFixViewDisappearAnimatorListener
                    .bindAction(recycler, layoutManagerHelper, fixView);
            animator.setListener(mFixViewDisappearAnimatorListener).start();
            isAddFixViewImmediately = false;
        } else {
            layoutManagerHelper.removeChildView(fixView);
            recycler.recycleView(fixView);
            isAddFixViewImmediately = false;
        }
    } else {
        layoutManagerHelper.removeChildView(fixView);
        recycler.recycleView(fixView);
        isAddFixViewImmediately = false;
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:FixLayoutHelper.java

示例7: 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

示例8: resetCardPosition

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
private ViewPropertyAnimator resetCardPosition() {
    if (rightView != null) {
        rightView.setAlpha(0);
    }
    if (leftView != null) {
        leftView.setAlpha(0);
    }

    //todo: figure out why i have to set translationX to 0
    return card.animate()
            .setDuration(SwipeDeck.ANIMATION_DURATION)
            .setInterpolator(new OvershootInterpolator(1.5f))
            .x(initialX)
            .y(initialY)
            .rotation(0)
            .translationX(0);
}
 
开发者ID:pao11,项目名称:SwipeDeckRelease,代码行数:18,代码来源:SwipeListener.java

示例9: listItemUpAnimSlow

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
public static void listItemUpAnimSlow(View view, int position,
                                      AnimatorListenerAdapter animatorListenerAdapter) {
    view.setTranslationY(150);
    view.setAlpha(0.f);
    ViewPropertyAnimator animate = view.animate();
    animate.translationY(0).alpha(1.f)
            .setStartDelay(70 * (position))
            .setInterpolator(new DecelerateInterpolator(2.f))
            .setDuration(400);

    if (animatorListenerAdapter != null) {
        animate.setListener(animatorListenerAdapter);
    }

    animate.withLayer().start();
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:17,代码来源:FeViewUtils.java

示例10: animateTilt

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates to rotation of all tabs to be reset to normal.
 *
 * @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 maxAngle
 *         The angle, the tabs may be rotated by at maximum, in degrees as a {@link Float}
 *         value
 * @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
 * @return True, if at least one tab was animated, false otherwise
 */
private boolean animateTilt(@NonNull final Interpolator interpolator, final float maxAngle,
                            @Nullable final AnimatorListener listener) {
    TabItemIterator iterator =
            new TabItemIterator.Builder(getTabSwitcher(), viewRecycler).reverse(true).create();
    TabItem tabItem;
    boolean result = false;

    while ((tabItem = iterator.next()) != null) {
        if (tabItem.isInflated()) {
            View view = tabItem.getView();

            if (getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, view) != 0) {
                ViewPropertyAnimator animation = view.animate();
                animation.setListener(new AnimationListenerWrapper(
                        createRevertOvershootAnimationListener(view,
                                !result ? listener : null)));
                animation.setDuration(Math.round(revertOvershootAnimationDuration *
                        (Math.abs(getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, view)) /
                                maxAngle)));
                animation.setInterpolator(interpolator);
                getArithmetics().animateRotation(Axis.ORTHOGONAL_AXIS, animation, 0);
                animation.setStartDelay(0);
                animation.start();
                result = true;
            }
        }
    }

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

示例11: animateCloseButtonVisibility

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates the visibility of a tab's close button.
 *
 * @param viewHolder
 *         The view holder, which holds a reference to the close button, whose visibility should
 *         be animated, as an instance of the class {@link AbstractTabViewHolder}. The view
 *         holder may not be null
 * @param show
 *         True, if the close button should be shown, false otherwise
 */
private void animateCloseButtonVisibility(@NonNull final AbstractTabViewHolder viewHolder,
                                          final boolean show) {
    ImageButton closeButton = viewHolder.closeButton;
    Boolean visible = (Boolean) closeButton.getTag(R.id.tag_visibility);

    if (visible == null || visible != show) {
        closeButton.setTag(R.id.tag_visibility, show);

        if (closeButton.getAnimation() != null) {
            closeButton.getAnimation().cancel();
        }

        ViewPropertyAnimator animation = closeButton.animate();
        animation.setListener(createCloseButtonVisibilityAnimationListener(viewHolder, show));
        animation.alpha(show ? 1 : 0);
        animation.setStartDelay(0);
        animation.setDuration(closeButtonVisibilityAnimationDuration);
        animation.start();
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:31,代码来源:TabletTabSwitcherLayout.java

示例12: animateSwipe

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates a tab to be swiped horizontally.
 *
 * @param tabItem
 *         The tab item, which corresponds to the tab, which should be swiped, as an instance of
 *         the class {@link TabItem}. The tab item may not be null
 * @param targetPosition
 *         The position on the x-axis, the tab should be moved to, in pixels as a {@link Float}
 *         value
 * @param selected
 *         True, if the tab should become the selected one, false otherwise
 * @param animationDuration
 *         The duration of the animation in milliseconds as a {@link Long} value
 * @param velocity
 *         The velocity of the drag gesture, which caused the tab to be swiped, in pixels per
 *         second as a {@link Float} value
 */
private void animateSwipe(@NonNull final TabItem tabItem, final float targetPosition,
                          final boolean selected, final long animationDuration,
                          final float velocity) {
    View view = contentViewRecycler.getView(tabItem.getTab());

    if (view != null) {
        float currentPosition = view.getX();
        float distance = Math.abs(targetPosition - currentPosition);
        float maxDistance = getTabSwitcher().getWidth() + swipedTabDistance;
        long duration = velocity > 0 ? Math.round((distance / velocity) * 1000) :
                Math.round(animationDuration * (distance / maxDistance));
        ViewPropertyAnimator animation = view.animate();
        animation.setListener(new AnimationListenerWrapper(
                selected ? createSwipeSelectedTabAnimationListener(tabItem) :
                        createSwipeNeighborAnimationListener(tabItem)));
        animation.setInterpolator(new AccelerateDecelerateInterpolator());
        animation.setDuration(duration);
        animation.setStartDelay(0);
        animation.x(targetPosition);
        animation.start();
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:40,代码来源:TabletTabSwitcherLayout.java

示例13: adaptEmptyView

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Adapts the visibility of the view, which is shown, when the tab switcher is empty.
 *
 * @param animationDuration
 *         The duration of the fade animation, which should be used to show or hide the view, in
 *         milliseconds as a {@link Long} value
 */
private void adaptEmptyView(final long animationDuration) {
    detachEmptyView();

    if (getModel().isEmpty()) {
        emptyView = getModel().getEmptyView();

        if (emptyView != null) {
            emptyView.setAlpha(0);
            FrameLayout.LayoutParams layoutParams =
                    new FrameLayout.LayoutParams(emptyView.getLayoutParams().width,
                            emptyView.getLayoutParams().height);
            layoutParams.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL;
            getTabSwitcher().addView(emptyView, 0, layoutParams);
            ViewPropertyAnimator animation = emptyView.animate();
            animation.setDuration(
                    animationDuration == -1 ? emptyViewAnimationDuration : animationDuration);
            animation.alpha(1);
            animation.start();
        }
    }
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:29,代码来源:PhoneTabSwitcherLayout.java

示例14: animateHideSwitcher

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates the position and size of a specific tab in order to hide 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 class
 *         {@link Interpolator}. The interpolator may not be null
 * @param delay
 *         The delay of the animation in milliseconds as a {@link Long} value
 * @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 animateHideSwitcher(@NonNull final AbstractItem item, final long duration,
                                 @NonNull final Interpolator interpolator, final long delay,
                                 @Nullable final AnimatorListener listener) {
    View view = item.getView();
    animateBottomMargin(view, -(tabInset + tabBorderWidth), duration, delay);
    ViewPropertyAnimator animation = view.animate();
    animation.setDuration(duration);
    animation.setInterpolator(interpolator);
    animation.setListener(new AnimationListenerWrapper(listener));
    getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation, 1);
    getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation, 1);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    getArithmetics().animatePosition(Axis.ORTHOGONAL_AXIS, animation, item,
            getTabSwitcher().getLayout() == Layout.PHONE_LANDSCAPE ? layoutParams.topMargin :
                    0);
    int selectedTabIndex = getModel().getSelectedTabIndex();

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

    animation.setStartDelay(delay);
    animation.start();
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:51,代码来源:PhoneTabSwitcherLayout.java

示例15: animateTilt

import android.view.ViewPropertyAnimator; //导入依赖的package包/类
/**
 * Animates to rotation of all tabs to be reset to normal.
 *
 * @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 maxAngle
 *         The angle, the tabs may be rotated by at maximum, in degrees as a {@link Float}
 *         value
 * @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
 * @return True, if at least one tab was animated, false otherwise
 */
private boolean animateTilt(@NonNull final Interpolator interpolator, final float maxAngle,
                            @Nullable final AnimatorListener listener) {
    ItemIterator iterator =
            new ItemIterator.Builder(getTabSwitcher(), tabViewRecycler).reverse(true).create();
    AbstractItem item;
    boolean result = false;

    while ((item = iterator.next()) != null) {
        if (item.isInflated() &&
                getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, item) != 0) {
            View view = item.getView();
            ViewPropertyAnimator animation = view.animate();
            animation.setListener(new AnimationListenerWrapper(
                    createRevertOvershootAnimationListener(item, !result ? listener : null)));
            animation.setDuration(Math.round(revertOvershootAnimationDuration *
                    (Math.abs(getArithmetics().getRotation(Axis.ORTHOGONAL_AXIS, item)) /
                            maxAngle)));
            animation.setInterpolator(interpolator);
            getArithmetics().animateRotation(Axis.ORTHOGONAL_AXIS, animation, 0);
            animation.setStartDelay(0);
            animation.start();
            result = true;
        }
    }

    return result;
}
 
开发者ID:michael-rapp,项目名称:ChromeLikeTabSwitcher,代码行数:42,代码来源:PhoneTabSwitcherLayout.java


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