List of usage examples for android.view View ALPHA
Property ALPHA
To view the source code for android.view View ALPHA.
Click Source Link
alpha
functionality handled by the View#setAlpha(float) and View#getAlpha() methods. From source file:Main.java
@NonNull private static AnimatorSet createRevealAnimation(View headline, View image, View startBtn, View pick1, View pick2) {//from w w w. j av a 2 s . c om AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 0, 1, 1); Animator anim1_2 = ObjectAnimator.ofFloat(headline, View.TRANSLATION_Y, -headline.getBottom(), 60, 0); Animator anim1_3 = ObjectAnimator.ofFloat(headline, View.SCALE_X, 0.1f, 0.475f, 1); Animator anim1_4 = ObjectAnimator.ofFloat(headline, View.SCALE_Y, 0.1f, 0.475f, 1); setBatchTiming(1000, 0, anim1_1, anim1_2, anim1_3, anim1_4); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4); Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 0, 1); Animator anim2_2 = ObjectAnimator.ofFloat(image, View.TRANSLATION_Y, image.getHeight() / 4, 0); setBatchTiming(800, 0, anim2_1, anim2_2); animAll.play(anim2_1).with(anim2_2).after(anim1_1); Animator anim3_1 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 0, 1); Animator anim3_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 0, 1); Animator anim3_3 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 0, 1); Animator anim3_4 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 0, 1); setBatchTiming(1800, 0, anim3_1, anim3_2, anim3_3, anim3_4); animAll.play(anim3_1).with(anim3_2).with(anim3_3).with(anim3_4).after(anim1_1); return animAll; }
From source file:Main.java
@NonNull private static AnimatorSet createDisappearAnim(View startBtn, View pick1, View pick2, View image, View headline) {//ww w . j ava 2 s . c om AnimatorSet animAll = new AnimatorSet(); Animator anim1_1 = ObjectAnimator.ofFloat(headline, View.ALPHA, 1, 0); Animator anim1_2 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0); Animator anim1_3 = ObjectAnimator.ofFloat(startBtn, View.ALPHA, 1, 0); Animator anim1_4 = ObjectAnimator.ofFloat(pick1, View.ALPHA, 1, 0); Animator anim1_5 = ObjectAnimator.ofFloat(pick2, View.ALPHA, 1, 0); setBatchTiming(400, 0, anim1_1, anim1_2, anim1_3, anim1_4, anim1_5); animAll.play(anim1_1).with(anim1_2).with(anim1_3).with(anim1_4).with(anim1_5); Interpolator interpolator2 = new DecelerateInterpolator(); Animator anim2_1 = ObjectAnimator.ofFloat(image, View.ALPHA, 1, 0); Animator anim2_2 = ObjectAnimator.ofFloat(image, View.SCALE_X, 1f, 2f); Animator anim2_3 = ObjectAnimator.ofFloat(image, View.SCALE_Y, 1f, 2f); anim2_1.setInterpolator(interpolator2); anim2_2.setInterpolator(interpolator2); anim2_3.setInterpolator(interpolator2); setBatchTiming(800, 0, anim2_1, anim2_2, anim2_3); animAll.play(anim2_1).with(anim2_2).with(anim2_3).after(anim1_1); return animAll; }
From source file:net.huannguyen.conductorexample.transition.DetailPushAnimChangeHandler.java
@NonNull @Override/*ww w.j av a 2 s . c o m*/ protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the to view is a CountryDetailView if (to == null || !(to instanceof CountryDetailView)) throw new IllegalArgumentException("The to view must be a CountryDetailView"); final CountryDetailView detailView = (CountryDetailView) to; // Set the button scale to 0 to make it invisible at the beginning. detailView.favouriteFab.setScaleX(0); detailView.favouriteFab.setScaleY(0); AnimatorSet animatorSet = new AnimatorSet(); AnimatorSet flagAndDetailAnim = new AnimatorSet(); // Hide the old view Animator hideFromViewAnim = ObjectAnimator.ofFloat(from, View.ALPHA, 1, 0); // Slide down the flag Animator flagAnim = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, -detailView.flagView.getHeight(), 0); // Slide up the details Animator detailAnim = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, detailView.detailGroup.getHeight(), 0); flagAndDetailAnim.playTogether(hideFromViewAnim, flagAnim, detailAnim); flagAndDetailAnim.setDuration(300); flagAndDetailAnim.setInterpolator(new FastOutSlowInInterpolator()); // Scale up the favourite fab PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0, 1); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0, 1); Animator favouriteAnim = ObjectAnimator .ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY).setDuration(200); animatorSet.playSequentially(flagAndDetailAnim, favouriteAnim); animatorSet.start(); return animatorSet; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateRemove(final ViewHolder holder) { endAnimation(holder);// w ww .j a v a2s . c o m final float prevAlpha = holder.itemView.getAlpha(); final Animator removeAnimator = ObjectAnimator.ofFloat(holder.itemView, View.ALPHA, 0f); removeAnimator.setDuration(getRemoveDuration()); removeAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); holder.itemView.setAlpha(prevAlpha); dispatchRemoveFinished(holder); } }); mRemoveAnimatorsList.add(removeAnimator); mAnimators.put(holder, removeAnimator); return true; }
From source file:ua.yyunikov.android.view.AdditionRemovalListView.java
public void removeWithAnimation(final AdditionRemovalAdapter.Item item, final View itemView) { final ObjectAnimator anim = ObjectAnimator.ofFloat(itemView, View.ALPHA, 0); anim.setDuration(ANIMATION_TIME);//from www .j ava2s. c o m ViewCompat.setHasTransientState(itemView, true); anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { remove(item); itemView.setAlpha(1); ViewCompat.setHasTransientState(itemView, false); } }); anim.start(); }
From source file:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java
@NonNull @Override//from w w w . jav a2 s . c o m protected Animator getAnimator(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush, boolean toAddedToContainer) { // Make sure the from view is a CountryDetailView if (from == null || !(from instanceof CountryDetailView)) throw new IllegalArgumentException("The from view must be a CountryDetailView"); if (to == null) throw new IllegalArgumentException("The to view must not be null"); final CountryDetailView detailView = (CountryDetailView) from; AnimatorSet animatorSet = new AnimatorSet(); // Set the to View's alpha to 0 to hide it at the beginning. to.setAlpha(0); // Scale down to hide the fab button PropertyValuesHolder fabScaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, 0); PropertyValuesHolder fabScaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0); Animator hideFabButtonAnimator = ObjectAnimator.ofPropertyValuesHolder(detailView.favouriteFab, fabScaleX, fabScaleY); // Slide up the flag Animator flagAnimator = ObjectAnimator.ofFloat(detailView.flagView, View.TRANSLATION_Y, 0, -detailView.flagView.getHeight()); // Slide down the details Animator detailAnimator = ObjectAnimator.ofFloat(detailView.detailGroup, View.TRANSLATION_Y, 0, detailView.detailGroup.getHeight()); // Show the new view Animator showToViewAnimator = ObjectAnimator.ofFloat(to, View.ALPHA, 0, 1); animatorSet.playTogether(hideFabButtonAnimator, flagAnimator, detailAnimator, showToViewAnimator); animatorSet.setDuration(300); animatorSet.setInterpolator(new FastOutLinearInInterpolator()); animatorSet.start(); return animatorSet; }
From source file:com.google.android.apps.muzei.util.AnimatedMuzeiLogoFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { mSubtitleView = view.findViewById(R.id.logo_subtitle); mLogoView = (AnimatedMuzeiLogoView) view.findViewById(R.id.animated_logo); mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() { @Override/*from w w w . ja va2s.c o m*/ public void onStateChange(int state) { if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) { mSubtitleView.setAlpha(0); mSubtitleView.setVisibility(View.VISIBLE); mSubtitleView.setTranslationY(-mSubtitleView.getHeight()); // Bug in older versions where set.setInterpolator didn't work AnimatorSet set = new AnimatorSet(); Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); set.setDuration(500).playTogether(a1, a2, a3); set.start(); if (mOnFillStartedCallback != null) { mOnFillStartedCallback.run(); } } } }); if (savedInstanceState == null) { reset(); } }
From source file:com.google.cloud.android.dialogflow.ui.AudioIndicatorView.java
private void startAnimating() { mAnimator = ObjectAnimator.ofFloat(this, View.ALPHA, 1.f, 0.3f); mAnimator.setRepeatCount(ObjectAnimator.INFINITE); mAnimator.setRepeatMode(ObjectAnimator.REVERSE); mAnimator.setDuration(1000);//from w ww. j a v a 2s. co m mAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); mAnimator.start(); }
From source file:org.hawkular.client.android.util.ViewTransformer.java
@UiThread public void show() { Animator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1); animator.setInterpolator(new FastOutSlowInInterpolator()); animator.setDuration(Durations.MEDIUM); animator.start();//from w w w . j a v a 2 s. com }
From source file:com.chromium.fontinstaller.util.ViewUtils.java
public static void reveal(Activity activity, View view, View sourceView, int colorRes) { if (activity == null || view == null || sourceView == null) return;/*from ww w.java 2 s. com*/ if (isLollipop()) { final ViewGroupOverlay groupOverlay = (ViewGroupOverlay) activity.getWindow().getDecorView() .getOverlay(); final Rect displayRect = new Rect(); view.getGlobalVisibleRect(displayRect); // Make reveal cover the display and status bar. final View revealView = new View(activity); revealView.setTop(displayRect.top); revealView.setBottom(displayRect.bottom); revealView.setLeft(displayRect.left); revealView.setRight(displayRect.right); revealView.setBackgroundColor(ContextCompat.getColor(activity, colorRes)); groupOverlay.add(revealView); final int[] clearLocation = new int[2]; sourceView.getLocationInWindow(clearLocation); clearLocation[0] += sourceView.getWidth() / 2; clearLocation[1] += sourceView.getHeight() / 2; final int revealCenterX = clearLocation[0] - revealView.getLeft(); final int revealCenterY = clearLocation[1] - revealView.getTop(); final double x1_2 = Math.pow(revealView.getLeft() - revealCenterX, 2); final double x2_2 = Math.pow(revealView.getRight() - revealCenterX, 2); final double y_2 = Math.pow(revealView.getTop() - revealCenterY, 2); final float revealRadius = (float) Math.max(Math.sqrt(x1_2 + y_2), Math.sqrt(x2_2 + y_2)); try { final Animator revealAnimator = ViewAnimationUtils.createCircularReveal(revealView, revealCenterX, revealCenterY, 0.0f, revealRadius); revealAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_mediumAnimTime)); final Animator alphaAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f); alphaAnimator .setDuration(activity.getResources().getInteger(android.R.integer.config_shortAnimTime)); alphaAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); view.startAnimation(AnimationUtils.loadAnimation(activity, R.anim.abc_fade_in)); view.setVisibility(View.VISIBLE); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(revealAnimator).before(alphaAnimator); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { groupOverlay.remove(revealView); } }); animatorSet.start(); } catch (IllegalStateException e) { Timber.i("View is detached - not animating"); } } else { view.setVisibility(View.VISIBLE); } }