本文整理汇总了Java中android.view.ViewPropertyAnimator.alpha方法的典型用法代码示例。如果您正苦于以下问题:Java ViewPropertyAnimator.alpha方法的具体用法?Java ViewPropertyAnimator.alpha怎么用?Java ViewPropertyAnimator.alpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewPropertyAnimator
的用法示例。
在下文中一共展示了ViewPropertyAnimator.alpha方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
}
示例3: createPeekAnimationListener
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
* Creates and returns an animation listener, which allows to hide a tab, which has been added
* by using a peek animation, when the animation has been ended.
*
* @param item
* The item, which corresponds to the tab, which has been added by using the peek
* animation, as an instance of the class {@link AbstractItem}. The item may not be
* null
* @param peekAnimation
* The peek animation 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
* AnimatorListener}. The listener may not be null
*/
@NonNull
private AnimatorListener createPeekAnimationListener(@NonNull final AbstractItem item,
@NonNull final PeekAnimation peekAnimation) {
return new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
super.onAnimationEnd(animation);
long totalDuration =
peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() :
peekAnimationDuration;
long duration = totalDuration / 3;
Interpolator interpolator =
peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() :
new AccelerateDecelerateInterpolator();
View view = item.getView();
getArithmetics().setPivot(Axis.DRAGGING_AXIS, item, tabTitleContainerHeight);
getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, item,
getArithmetics().getSize(Axis.ORTHOGONAL_AXIS, item) / 2f);
ViewPropertyAnimator animator = view.animate();
animator.setDuration(duration);
animator.setStartDelay(duration);
animator.setInterpolator(interpolator);
animator.setListener(
new AnimationListenerWrapper(createRevertPeekAnimationListener(item)));
animator.alpha(0);
getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animator, item,
getArithmetics().getPosition(Axis.DRAGGING_AXIS, item) * 1.5f);
getArithmetics().animateScale(Axis.DRAGGING_AXIS, animator, 0);
getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animator, 0);
animator.start();
}
};
}
示例4: buildAndStartAnimation
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
private void buildAndStartAnimation(View view) {
ViewPropertyAnimator propertyAnimator = view.animate();
propertyAnimator.alpha(0);
propertyAnimator.scaleX(0).scaleY(0);
propertyAnimator.setDuration(500l);
propertyAnimator.setInterpolator(new LinearInterpolator());
propertyAnimator.start();
}
示例5: animateSwipe
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
* Animates the position, size and alpha of a specific tab in order to swipe it
* orthogonally.
*
* @param item
* The item, corresponds to the tab, which should be animated, as an instance of the
* class {@link AbstractItem}. The item may not be null
* @param remove
* True, if the tab should be removed after the animation has finished, false otherwise
* @param delayMultiplier
* The multiplied, which should be used to calculate the delay after which the animation
* should be started, by being multiplied with the default delay, as an {@link Integer}
* value
* @param swipeAnimation
* The animation, which should be used, as an instance of the class {@link
* SwipeAnimation}. The animation may not be null
* @param listener
* The listener, which should be notified about the progress of the animation, as an
* instance of the type {@link AnimatorListener} or null, if no listener should be
* notified
*/
private void animateSwipe(@NonNull final AbstractItem item, final boolean remove,
final int delayMultiplier,
@NonNull final SwipeAnimation swipeAnimation,
@Nullable final AnimatorListener listener) {
View view = item.getView();
float currentScale = getArithmetics().getScale(item, true);
float swipePosition = calculateSwipePosition();
float targetPosition = remove ?
(swipeAnimation.getDirection() == SwipeDirection.LEFT_OR_TOP ? -1 * swipePosition :
swipePosition) : 0;
float currentPosition = getArithmetics().getPosition(Axis.ORTHOGONAL_AXIS, item);
float distance = Math.abs(targetPosition - currentPosition);
long animationDuration = swipeAnimation.getDuration() != -1 ? swipeAnimation.getDuration() :
Math.round(swipeAnimationDuration * (distance / swipePosition));
ViewPropertyAnimator animation = view.animate();
animation.setInterpolator(
swipeAnimation.getInterpolator() != null ? swipeAnimation.getInterpolator() :
new AccelerateDecelerateInterpolator());
animation.setListener(new AnimationListenerWrapper(listener));
animation.setDuration(animationDuration);
getArithmetics()
.animatePosition(Axis.ORTHOGONAL_AXIS, animation, item, targetPosition, true);
getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation,
remove ? swipedTabScale * currentScale : currentScale);
getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation,
remove ? swipedTabScale * currentScale : currentScale);
animation.alpha(remove ? swipedTabAlpha : 1);
animation.setStartDelay(delayMultiplier * calculateAnimationDelay(animationDuration));
animation.start();
}
示例6: animateViewHorizontally
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
private void animateViewHorizontally(float dX, int duration, boolean shouldHide, AnimatorCompletionListener listener) {
float animatingDistance = viewStartX + dX;
ViewPropertyAnimator animator = animatingView.animate()
.x(animatingDistance)
.setDuration(duration)
.setListener(listener);
if (shouldHide) {
animator.alpha(0);
}
animator.start();
}
示例7: alpha
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
public ViewPropertyAnimator alpha(float value) {
ViewPropertyAnimator n = (ViewPropertyAnimator) this.mNative.get();
if (n != null) {
n.alpha(value);
}
return this;
}
示例8: animateSwipe
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
* Animates the position, size and alpha of a specific tab item in order to swipe it
* orthogonally.
*
* @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 remove
* True, if the tab should be removed after the animation has finished, false otherwise
* @param delay
* The delay after which the animation should be started in milliseconds as a {@link
* Long} value
* @param swipeAnimation
* The animation, which should be used, as an instance of the class {@link
* SwipeAnimation}. The animation may not be null
* @param listener
* The listener, which should be notified about the progress of the animation, as an
* instance of the type {@link AnimatorListener} or null, if no listener should be
* notified
*/
private void animateSwipe(@NonNull final TabItem tabItem, final boolean remove,
final long delay, @NonNull final SwipeAnimation swipeAnimation,
@Nullable final AnimatorListener listener) {
View view = tabItem.getView();
float currentScale = getArithmetics().getScale(view, true);
float swipePosition = calculateSwipePosition();
float targetPosition = remove ?
(swipeAnimation.getDirection() == SwipeDirection.LEFT ? -1 * swipePosition :
swipePosition) : 0;
float currentPosition = getArithmetics().getPosition(Axis.ORTHOGONAL_AXIS, view);
float distance = Math.abs(targetPosition - currentPosition);
long animationDuration = swipeAnimation.getDuration() != -1 ? swipeAnimation.getDuration() :
Math.round(swipeAnimationDuration * (distance / swipePosition));
ViewPropertyAnimator animation = view.animate();
animation.setInterpolator(
swipeAnimation.getInterpolator() != null ? swipeAnimation.getInterpolator() :
new AccelerateDecelerateInterpolator());
animation.setListener(new AnimationListenerWrapper(listener));
animation.setDuration(animationDuration);
getArithmetics()
.animatePosition(Axis.ORTHOGONAL_AXIS, animation, view, targetPosition, true);
getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animation,
remove ? swipedTabScale * currentScale : currentScale);
getArithmetics().animateScale(Axis.DRAGGING_AXIS, animation,
remove ? swipedTabScale * currentScale : currentScale);
animation.alpha(remove ? swipedTabAlpha : 1);
animation.setStartDelay(delay);
animation.start();
}
示例9: createPeekAnimationListener
import android.view.ViewPropertyAnimator; //导入方法依赖的package包/类
/**
* Creates and returns an animation listener, which allows to hide a tab, which has been added
* by using a peek animation, when the animation has been ended.
*
* @param tabItem
* The tab item, which corresponds to the tab, which has been added by using the peek
* animation, as an instance of the class {@link TabItem}. The tab item may not be null
* @param peekAnimation
* The peek animation 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
* AnimatorListener}. The listener may not be null
*/
@NonNull
private AnimatorListener createPeekAnimationListener(@NonNull final TabItem tabItem,
@NonNull final PeekAnimation peekAnimation) {
return new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
super.onAnimationEnd(animation);
long totalDuration =
peekAnimation.getDuration() != -1 ? peekAnimation.getDuration() :
peekAnimationDuration;
long duration = totalDuration / 3;
Interpolator interpolator =
peekAnimation.getInterpolator() != null ? peekAnimation.getInterpolator() :
new AccelerateDecelerateInterpolator();
View view = tabItem.getView();
getArithmetics().setPivot(Axis.DRAGGING_AXIS, view, tabTitleContainerHeight);
getArithmetics().setPivot(Axis.ORTHOGONAL_AXIS, view,
getArithmetics().getSize(Axis.ORTHOGONAL_AXIS, view) / 2f);
ViewPropertyAnimator animator = view.animate();
animator.setDuration(duration);
animator.setStartDelay(duration);
animator.setInterpolator(interpolator);
animator.setListener(
new AnimationListenerWrapper(createRevertPeekAnimationListener(tabItem)));
animator.alpha(0);
getArithmetics().animatePosition(Axis.DRAGGING_AXIS, animator, view,
getArithmetics().getPosition(Axis.DRAGGING_AXIS, view) * 1.5f, false);
getArithmetics().animateScale(Axis.DRAGGING_AXIS, animator, 0);
getArithmetics().animateScale(Axis.ORTHOGONAL_AXIS, animator, 0);
animator.start();
}
};
}