List of usage examples for android.view View TRANSLATION_Y
Property TRANSLATION_Y
To view the source code for android.view View TRANSLATION_Y.
Click Source Link
translationY
functionality handled by the View#setTranslationY(float) and View#getTranslationY() methods. From source file:Main.java
public static ObjectAnimator createTranslationYAnimator(View view, float from, float to) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, from, to); return animator; }
From source file:Main.java
public static void slowViewAnimation(View view) { ObjectAnimator translationY = ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, -200f, 0f); translationY.setDuration(5000);/* w w w .j ava 2 s .co m*/ AnimatorSet translateSlowly = new AnimatorSet(); translateSlowly.playTogether(translationY); translateSlowly.start(); }
From source file:Main.java
@NonNull private static AnimatorSet createRevealAnimation(View headline, View btnPanel, View recyclerView, View locationTxt) {//from w ww . j a v a 2 s .c o m 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(btnPanel, View.ALPHA, 0, 1); Animator anim2_2 = ObjectAnimator.ofFloat(btnPanel, View.TRANSLATION_Y, btnPanel.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(recyclerView, View.ALPHA, 0, 1); Animator anim3_2 = ObjectAnimator.ofFloat(locationTxt, View.ALPHA, 0, 1); setBatchTiming(1800, 0, anim3_1, anim3_2); animAll.play(anim3_1).with(anim3_2).after(anim1_1); return animAll; }
From source file:Main.java
/** * shake y// w w w .j a va 2 s .c om * * @param v * @param offset * @param duration * @param times */ public static void shakeY(View v, float offset, long duration, float times) { ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.TRANSLATION_Y, 0, offset); animator.setDuration(duration); animator.setInterpolator(new CycleInterpolator(times)); animator.start(); }
From source file:Main.java
/** * translation y//from w w w . j av a 2 s .c o m * * @param v * @param fromY * @param toY * @param duration * @param animatorListener */ public static void translationY(View v, float fromY, float toY, int duration, Animator.AnimatorListener animatorListener) { ObjectAnimator animator = ObjectAnimator.ofFloat(v, View.TRANSLATION_Y, fromY, toY); animator.setDuration(duration); if (animatorListener != null) { animator.addListener(animatorListener); } animator.start(); }
From source file:Main.java
@NonNull private static AnimatorSet createRevealAnimation(View headline, View image, View startBtn, View pick1, View pick2) {/*w ww . j av a 2s .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:net.huannguyen.conductorexample.transition.DetailPushAnimChangeHandler.java
@NonNull @Override/*from w w w.ja va2 s .co 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:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java
@NonNull @Override/* w w w .j ava2 s .co 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/*www.j av a 2s . 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.android.apps.muzei.TutorialFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { view.findViewById(R.id.tutorial_icon_affordance).setOnClickListener(new View.OnClickListener() { @Override/* ww w .j a va 2s . c o m*/ public void onClick(View view) { FirebaseAnalytics.getInstance(getContext()).logEvent(FirebaseAnalytics.Event.TUTORIAL_COMPLETE, null); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); sp.edit().putBoolean(PREF_SEEN_TUTORIAL, true).apply(); } }); if (savedInstanceState == null) { float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); View mainTextView = view.findViewById(R.id.tutorial_main_text); mainTextView.setAlpha(0); mainTextView.setTranslationY(-animateDistance / 5); View subTextView = view.findViewById(R.id.tutorial_sub_text); subTextView.setAlpha(0); subTextView.setTranslationY(-animateDistance / 5); final View affordanceView = view.findViewById(R.id.tutorial_icon_affordance); affordanceView.setAlpha(0); affordanceView.setTranslationY(animateDistance); View iconTextView = view.findViewById(R.id.tutorial_icon_text); iconTextView.setAlpha(0); iconTextView.setTranslationY(animateDistance); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(500); mAnimator.setDuration(250); mAnimator.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f)); mAnimator.start(); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(2000); // Bug in older versions where set.setInterpolator didn't work Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0); ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); a3.setInterpolator(interpolator); a4.setInterpolator(interpolator); mAnimator.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (isAdded()) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } } }); } mAnimator.start(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } }