List of usage examples for android.animation ObjectAnimator ofFloat
public static <T> ObjectAnimator ofFloat(T target, Property<T, Float> property, float... values)
From source file:com.mediatek.galleryfeature.stereo.segment.background.StereoBackgroundActivity.java
private void loadXML() { setContentView(R.layout.m_stereo_background_activity); mActionBar = getActionBar();// w w w. j a v a2 s .c o m mActionBar.setBackgroundDrawable(new ColorDrawable(ACTIONBAR_BACKGROUND_COLOR)); mActionBar.setSubtitle(null); mActionBar.setCustomView(R.layout.m_stereo_actionbar); mSaveButton = mActionBar.getCustomView(); View clickableRegion = mSaveButton.findViewById(R.id.stereo_segment_save); clickableRegion.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { saveSynthedImage(); } }); setActionBarDisplayOptions(mActionBar, true, true); mImageShowBackground = (ImageShow) findViewById(R.id.imageShowBackground); mButtonCollapse = findViewById(R.id.collapse); mBackgroundThumbnailList = findViewById(R.id.main_panel_container); mBackgroundStrip = findViewById(R.id.mainPanel); mButtonCollapse.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mIsBottomStripIn) { ((ImageView) (mButtonCollapse)).setImageBitmap(mBitmapExpand); ObjectAnimator animator = ObjectAnimator.ofFloat(mBackgroundStrip, "translationY", mBackgroundThumbnailList.getHeight()); animator.setDuration(THUMBNAIL_TRACK_ANIMATION_DURATION).start(); mIsBottomStripIn = false; } else { ((ImageView) (mButtonCollapse)).setImageBitmap(mBitmapCollapse); ObjectAnimator animator = ObjectAnimator.ofFloat(mBackgroundStrip, "translationY", 0); animator.setDuration(THUMBNAIL_TRACK_ANIMATION_DURATION).start(); mIsBottomStripIn = true; } } }); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionDetailFragment.java
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private void setOrAnimateIconTo(final ImageView imageView, final int imageResId, boolean animate) { if (UIUtils.hasICS() && imageView.getTag() != null) { if (imageView.getTag() instanceof Animator) { Animator anim = (Animator) imageView.getTag(); anim.end();/* w w w. j ava 2 s .c o m*/ imageView.setAlpha(1f); } } animate = animate && UIUtils.hasICS(); if (animate) { int duration = getResources().getInteger(android.R.integer.config_shortAnimTime); Animator outAnimator = ObjectAnimator.ofFloat(imageView, View.ALPHA, 0f); outAnimator.setDuration(duration / 2); outAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setImageResource(imageResId); } }); AnimatorSet inAnimator = new AnimatorSet(); outAnimator.setDuration(duration); inAnimator.playTogether(ObjectAnimator.ofFloat(imageView, View.ALPHA, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_X, 0f, 1f), ObjectAnimator.ofFloat(imageView, View.SCALE_Y, 0f, 1f)); AnimatorSet set = new AnimatorSet(); set.playSequentially(outAnimator, inAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { imageView.setTag(null); } }); imageView.setTag(set); set.start(); } else { mHandler.post(new Runnable() { @Override public void run() { imageView.setImageResource(imageResId); } }); } }
From source file:com.sbgapps.scoreit.ui.ScoreItActivity.java
public void animateLapContainer() { ObjectAnimator animY;//from w w w. ja va2s . c o m float height = mLapContainer.getHeight(); if (null != mLap) { animY = ObjectAnimator.ofFloat(mLapContainer, "y", 0); } else { mLapContainer.scrollTo(0, 0); animY = ObjectAnimator.ofFloat(mLapContainer, "y", height); } animY.start(); }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
private void onResult(final String result) { // Calculate the values needed to perform the scale and translation animations, // accounting for how the scale will affect the final position of the text. final float resultScale = mInputEditText.getVariableTextSize(result) / mResultEditText.getTextSize(); final float resultTranslationX = (1.0f - resultScale) * (mResultEditText.getWidth() / 2.0f - mResultEditText.getPaddingEnd()); final float resultTranslationY = (1.0f - resultScale) * //TODO delete unnecessary lines for animation (mResultEditText.getHeight() / 2.0f - mResultEditText.getPaddingBottom()) + (mInputEditText.getBottom() - mResultEditText.getBottom()) + (mResultEditText.getPaddingBottom() - mInputEditText.getPaddingBottom()); final float inputTranslationY = -mInputEditText.getBottom(); // Use a value animator to fade to the final text color over the course of the animation. final int resultTextColor = mResultEditText.getCurrentTextColor(); final int inputEditText = mInputEditText.getCurrentTextColor(); final ValueAnimator textColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), resultTextColor, inputEditText);/*w w w. j a v a2 s . c o m*/ textColorAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { mResultEditText.setTextColor((int) valueAnimator.getAnimatedValue()); } }); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.playTogether(textColorAnimator, ObjectAnimator.ofFloat(mResultEditText, View.SCALE_X, resultScale), ObjectAnimator.ofFloat(mResultEditText, View.SCALE_Y, resultScale), ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_X, resultTranslationX), ObjectAnimator.ofFloat(mResultEditText, View.TRANSLATION_Y, resultTranslationY), ObjectAnimator.ofFloat(mInputEditText, View.TRANSLATION_Y, inputTranslationY)); animatorSet.setDuration(getResources().getInteger(android.R.integer.config_longAnimTime)); animatorSet.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mResultEditText.setText(result); } @Override public void onAnimationEnd(Animator animation) { // Reset all of the values modified during the animation. mResultEditText.setTextColor(resultTextColor); mResultEditText.setScaleX(1.0f); mResultEditText.setScaleY(1.0f); mResultEditText.setTranslationX(0.0f); mResultEditText.setTranslationY(0.0f); mInputEditText.setTranslationY(0.0f); // Finally update the input to use the current result. mInputEditText.setText(result); //TODO figure out how to reset after equal sign without changing input text mResultEditText.getEditableText().clear(); setState(CalculatorState.RESULT); mCurrentAnimator = null; } }); mCurrentAnimator = animatorSet; animatorSet.start(); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void fadeIn(View v) { v.setAlpha(0f);//from w w w. j a v a 2 s .c o m ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", 1f); alphaAnimator .setDuration(v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.start(); }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation/* ww w. j a v a2 s .c o m*/ * Animation for timer text slide to center */ public void animSlideClockToCenter() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yCenterValue); } else { ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1.5f); ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1.5f); scaleUpY.setDuration(animTimerDuration); scaleUpX.setDuration(animTimerDuration); AnimatorSet scaleUp = new AnimatorSet(); scaleUp.play(scaleUpX).with(scaleUpY); timerClockView.animate().y(yCenterValue); scaleUp.start(); } }
From source file:com.example.piechart3d.PieChart3DView.java
@SuppressLint("NewApi") public void animateV(float velocity) { Log.d("appOnF", "Cancle"); if (mZAnimator != null) mZAnimator.cancel();//from w w w .java 2 s . c om mZAnimator = ObjectAnimator.ofFloat(mRenderer, "angle_z", mRenderer.angle_z + (60 * velocity)); mZAnimator.setDuration(2000); mZAnimator.addListener(new AnimatorListener() { @Override public void onAnimationCancel(final Animator animation) { } @Override public void onAnimationEnd(final Animator animation) { // progressBar.setProgress(progress); } @Override public void onAnimationRepeat(final Animator animation) { } @Override public void onAnimationStart(final Animator animation) { } }); // mProgressBarAnimator.reverse(); mZAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { } }); DecelerateInterpolator di = new DecelerateInterpolator(1.0f); mZAnimator.setInterpolator(di); mZAnimator.start(); }
From source file:com.luanthanhthai.android.liteworkouttimer.TimerFragment.java
/** * Property Animation// w w w . j a v a 2 s .c o m * Animation for timer clock slide up to original position */ public void animSlideClockUp() { timerClockView.animate().setDuration(animTimerDuration); if (getOrientation() == Configuration.ORIENTATION_PORTRAIT) { timerClockView.animate().y(yOriginalValue); } else { ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(timerClockView, "scaleY", 1f); ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(timerClockView, "scaleX", 1f); scaleDownY.setDuration(animTimerDuration); scaleDownX.setDuration(animTimerDuration); AnimatorSet scaleDown = new AnimatorSet(); scaleDown.play(scaleDownX).with(scaleDownY); timerClockView.animate().y(yOriginalValue); scaleDown.start(); } }
From source file:com.boko.vimusic.ui.activities.AudioPlayerActivity.java
/** * @param v/*from ww w . jav a2 s . c o m*/ * The view to animate * @param alpha * The alpha to apply */ private void fade(final View v, final float alpha) { final ObjectAnimator fade = ObjectAnimator.ofFloat(v, "alpha", alpha); fade.setInterpolator( AnimationUtils.loadInterpolator(this, android.R.anim.accelerate_decelerate_interpolator)); fade.setDuration(400); fade.start(); }
From source file:com.android.systemui.statusbar.phone.NotificationPanelView.java
private void startClockAnimation(int y) { if (mClockAnimationTarget == y) { return;/*from w w w . j a va2 s .c o m*/ } mClockAnimationTarget = y; getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { getViewTreeObserver().removeOnPreDrawListener(this); if (mClockAnimator != null) { mClockAnimator.removeAllListeners(); mClockAnimator.cancel(); } mClockAnimator = ObjectAnimator.ofFloat(mKeyguardStatusView, View.Y, mClockAnimationTarget); mClockAnimator.setInterpolator(mFastOutSlowInInterpolator); mClockAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_STANDARD); mClockAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mClockAnimator = null; mClockAnimationTarget = -1; } }); mClockAnimator.start(); return true; } }); }