List of usage examples for android.animation PropertyValuesHolder ofFloat
public static PropertyValuesHolder ofFloat(Property<?, Float> property, float... values)
From source file:by.gdgminsk.animationguide.util.AnimUtils.java
public static void scaleIn(final View view, int delay) { view.setAlpha(0.0f);/*from www . ja v a 2s .c o m*/ view.setScaleX(0.0f); view.setScaleY(0.0f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1.0f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); ObjectAnimator scaleInAnimation = ObjectAnimator.ofPropertyValuesHolder(view, alpha, scaleX, scaleY); scaleInAnimation.setDuration(view.getResources().getInteger(R.integer.duration_fab_scale_in)); scaleInAnimation.setStartDelay(delay); scaleInAnimation.setInterpolator(EASE_IN_INTERPOLATOR); scaleInAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setAlpha(1.0f); view.setScaleX(1.0f); view.setScaleY(1.0f); } }); scaleInAnimation.start(); }
From source file:net.huannguyen.conductorexample.transition.DetailPopAnimChangeHandler.java
@NonNull @Override/* w ww . j a v 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:by.gdgminsk.animationguide.util.AnimUtils.java
public static void scaleOut(final View view, int delay) { PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.0f); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0.4f); ObjectAnimator scaleOutAnimation = ObjectAnimator.ofPropertyValuesHolder(view, alpha, scaleX, scaleY); scaleOutAnimation.setInterpolator(EASE_OUT_INTERPOLATOR); scaleOutAnimation.addListener(new AnimatorListenerAdapter() { @Override/* www . j ava 2s .co m*/ public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } @Override public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } @Override public void onAnimationCancel(Animator animation) { view.setScaleX(0.0f); view.setScaleY(0.0f); view.setVisibility(View.GONE); } }); scaleOutAnimation.setDuration(view.getResources().getInteger(R.integer.duration_fab_scale_out)); scaleOutAnimation.setStartDelay(delay); scaleOutAnimation.start(); }
From source file:com.taobao.weex.ui.animation.TransformParser.java
public static PropertyValuesHolder[] toHolders(Map<Property<View, Float>, Float> transformMap) { PropertyValuesHolder[] holders = new PropertyValuesHolder[transformMap.size()]; int i = 0;/*from ww w . j a v a 2 s .co m*/ for (Map.Entry<Property<View, Float>, Float> entry : transformMap.entrySet()) { holders[i] = PropertyValuesHolder.ofFloat(entry.getKey(), entry.getValue()); i++; } return holders; }
From source file:com.android.clear.reminder.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*www . ja v a 2 s . c om*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.sysdata.widget.accordion.ItemAnimator.java
@Override public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) { endAnimation(holder);/*from www .j a v a 2s . co m*/ final int deltaX = toX - fromX; final int deltaY = toY - fromY; final long moveDuration = getMoveDuration(); if (deltaX == 0 && deltaY == 0) { dispatchMoveFinished(holder); return false; } final View view = holder.itemView; final float prevTranslationX = view.getTranslationX(); final float prevTranslationY = view.getTranslationY(); view.setTranslationX(-deltaX); view.setTranslationY(-deltaY); final ObjectAnimator moveAnimator; if (deltaX != 0 && deltaY != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX, moveY); } else if (deltaX != 0) { final PropertyValuesHolder moveX = PropertyValuesHolder.ofFloat(TRANSLATION_X, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveX); } else { final PropertyValuesHolder moveY = PropertyValuesHolder.ofFloat(TRANSLATION_Y, 0f); moveAnimator = ObjectAnimator.ofPropertyValuesHolder(holder.itemView, moveY); } moveAnimator.setDuration(moveDuration); moveAnimator.setInterpolator(new FastOutSlowInInterpolator()); moveAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animator) { dispatchMoveStarting(holder); } @Override public void onAnimationEnd(Animator animator) { animator.removeAllListeners(); mAnimators.remove(holder); view.setTranslationX(prevTranslationX); view.setTranslationY(prevTranslationY); dispatchMoveFinished(holder); } }); mMoveAnimatorsList.add(moveAnimator); mAnimators.put(holder, moveAnimator); return true; }
From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java
public void toggleVisibleTitles() { // Use these for custom animations. final FragmentManager fm = getSupportFragmentManager(); final TitlesFragment f = (TitlesFragment) fm.findFragmentById(R.id.frag_title); final View titlesView = f.getView(); mLabelIndex = 1 - mLabelIndex;/*from w ww. ja v a2s . co m*/ // Determine if we're in portrait, and whether we're showing or hiding the titles // with this toggle. final boolean isPortrait = getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; final boolean shouldShow = f.isHidden() || mCurrentTitlesAnimator != null; // Cancel the current titles animation if there is one. if (mCurrentTitlesAnimator != null) mCurrentTitlesAnimator.cancel(); // Begin setting up the object animator. We'll animate the bottom or right edge of the // titles view, as well as its alpha for a fade effect. ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(titlesView, PropertyValuesHolder.ofInt(isPortrait ? "bottom" : "right", shouldShow ? getResources().getDimensionPixelSize(R.dimen.titles_size) : 0), PropertyValuesHolder.ofFloat("alpha", shouldShow ? 1 : 0)); // At each step of the animation, we'll perform layout by calling setLayoutParams. final ViewGroup.LayoutParams lp = titlesView.getLayoutParams(); objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { public void onAnimationUpdate(ValueAnimator valueAnimator) { // *** WARNING ***: triggering layout at each animation frame highly impacts // performance so you should only do this for simple layouts. More complicated // layouts can be better served with individual animations on child views to // avoid the performance penalty of layout. if (isPortrait) { lp.height = (Integer) valueAnimator.getAnimatedValue(); } else { lp.width = (Integer) valueAnimator.getAnimatedValue(); } titlesView.setLayoutParams(lp); } }); if (shouldShow) { fm.beginTransaction().show(f).commit(); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animator) { mCurrentTitlesAnimator = null; } }); } else { objectAnimator.addListener(new AnimatorListenerAdapter() { boolean canceled; @Override public void onAnimationCancel(Animator animation) { canceled = true; super.onAnimationCancel(animation); } @Override public void onAnimationEnd(Animator animator) { if (canceled) return; mCurrentTitlesAnimator = null; fm.beginTransaction().hide(f).commit(); } }); } // Start the animation. objectAnimator.start(); mCurrentTitlesAnimator = objectAnimator; invalidateOptionsMenu(); // Manually trigger onNewIntent to check for ACTION_DIALOG. onNewIntent(getIntent()); }
From source file:la.marsave.fullscreentest.MainActivity.java
/** * This method animates the image fragment into the background by both * scaling and rotating the fragment's view, as well as adding a * translucent dark hover view to inform the user that it is inactive. *//* w ww . j ava 2 s . c o m*/ public void slideBack(Animator.AnimatorListener listener) { View movingFragmentView = mInfiniteViewPager; PropertyValuesHolder rotateX = PropertyValuesHolder.ofFloat("rotationY", 40f); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.8f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.8f); ObjectAnimator movingFragmentAnimator = ObjectAnimator.ofPropertyValuesHolder(movingFragmentView, rotateX, scaleX, scaleY); ObjectAnimator darkHoverViewAnimator = ObjectAnimator.ofFloat(mDarkHoverView, "alpha", 0.0f, 0.5f); ObjectAnimator movingFragmentRotator = ObjectAnimator.ofFloat(movingFragmentView, "rotationY", 0); movingFragmentRotator.setStartDelay(getResources().getInteger(R.integer.half_slide_up_down_duration)); AnimatorSet s = new AnimatorSet(); s.playTogether(movingFragmentAnimator, darkHoverViewAnimator, movingFragmentRotator); s.addListener(listener); s.start(); }
From source file:com.hannesdorfmann.FeedAdapter.java
private void bindDesignerNewsStory(final Story story, final DesignerNewsStoryHolder holder) { holder.title.setText(story.title);//from w ww. j a va 2s . co m holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomTabActivityHelper.openCustomTab(host, DesignerNewsStory.getCustomTabIntent(host, story, null).build(), Uri.parse(story.url)); } }); holder.comments.setText(String.valueOf(story.comment_count)); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View commentsView) { final Intent intent = new Intent(); intent.setClass(host, DesignerNewsStory.class); intent.putExtra(DesignerNewsStory.EXTRA_STORY, story); final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(holder.itemView, host.getString(R.string.transition_story_title_background)), Pair.create(holder.itemView, host.getString(R.string.transition_story_background))); host.startActivity(intent, options.toBundle()); } }); if (pocketIsInstalled) { holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble... holder.pocket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final ImageButton pocketButton = (ImageButton) view; // actually add to pocket PocketUtils.addToPocket(host, story.url); // setup for anim holder.itemView.setHasTransientState(true); ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(false); final int initialLeft = pocketButton.getLeft(); final int initialTop = pocketButton.getTop(); final int translatedLeft = (holder.itemView.getWidth() - pocketButton.getWidth()) / 2; final int translatedTop = initialTop - ((holder.itemView.getHeight() - pocketButton.getHeight()) / 2); final ArcMotion arc = new ArcMotion(); // animate the title & pocket icon up, scale the pocket icon up PropertyValuesHolder pvhTitleUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -(holder.itemView.getHeight() / 5)); PropertyValuesHolder pvhTitleFade = PropertyValuesHolder.ofFloat(View.ALPHA, 0.54f); Animator titleMoveFadeOut = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleUp, pvhTitleFade); Animator pocketMoveUp = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(initialLeft, initialTop, translatedLeft, translatedTop)); PropertyValuesHolder pvhPocketScaleUpX = PropertyValuesHolder.ofFloat(View.SCALE_X, 3f); PropertyValuesHolder pvhPocketScaleUpY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 3f); Animator pocketScaleUp = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleUpX, pvhPocketScaleUpY); ObjectAnimator pocketFadeUp = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 255); AnimatorSet up = new AnimatorSet(); up.playTogether(titleMoveFadeOut, pocketMoveUp, pocketScaleUp, pocketFadeUp); up.setDuration(300); up.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); // animate everything back into place PropertyValuesHolder pvhTitleMoveUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f); PropertyValuesHolder pvhTitleFadeUp = PropertyValuesHolder.ofFloat(View.ALPHA, 1f); Animator titleMoveFadeIn = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleMoveUp, pvhTitleFadeUp); Animator pocketMoveDown = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(translatedLeft, translatedTop, 0, 0)); PropertyValuesHolder pvhPocketScaleDownX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f); PropertyValuesHolder pvhPocketScaleDownY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f); Animator pvhPocketScaleDown = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleDownX, pvhPocketScaleDownY); ObjectAnimator pocketFadeDown = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 138); AnimatorSet down = new AnimatorSet(); down.playTogether(titleMoveFadeIn, pocketMoveDown, pvhPocketScaleDown, pocketFadeDown); down.setDuration(300); down.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); down.setStartDelay(500); // play it AnimatorSet upDown = new AnimatorSet(); upDown.playSequentially(up, down); // clean up upDown.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(true); holder.itemView.setHasTransientState(false); } }); upDown.start(); } }); } }
From source file:com.example.grayapps.contextaware.BarFragment.java
private void showTooltipOne() { ArrayList<ArrayList<Rect>> areas = new ArrayList<>(); areas.add(mChartOne.getEntriesArea(0)); // areas.add(mChartOne.getEntriesArea(1)); for (int i = 0; i < areas.size(); i++) { for (int j = 0; j < areas.get(i).size(); j++) { Tooltip tooltip = new Tooltip(getActivity(), R.layout.barchart_one_tooltip, R.id.value); tooltip.prepare(areas.get(i).get(j), mNewValues[i]); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tooltip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1)); tooltip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0)); }/*www . j av a 2 s . c om*/ mChartOne.showTooltip(tooltip, true); } } }