List of usage examples for android.view.animation AlphaAnimation setDuration
public void setDuration(long durationMillis)
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Create dynamically an android animation for a coin or a bill droping into * the moneybox.//from w w w . j a v a 2 s . c om * * @param img * ImageView to receive the animation * @param layout * Layout that paint the image * @param curr * Currency value of the image * @return Set of animations to apply to the image */ private AnimationSet createDropAnimation(ImageView img, View layout, CurrencyValueDef curr) { AnimationSet result; result = new AnimationSet(false); result.setFillAfter(true); // Fade in AlphaAnimation fadeIn; fadeIn = new AlphaAnimation(0.0f, 1.0f); fadeIn.setDuration(300); result.addAnimation(fadeIn); // drop TranslateAnimation drop; int bottom; bottom = Math.abs(layout.getHeight() - img.getLayoutParams().height); drop = new TranslateAnimation(1.0f, 1.0f, 1.0f, bottom); drop.setStartOffset(300); drop.setDuration(1500); if (curr.getType() == CurrencyValueDef.MoneyType.COIN) { drop.setInterpolator(new BounceInterpolator()); } else { // drop.setInterpolator(new DecelerateInterpolator(0.7f)); drop.setInterpolator(new AnticipateOvershootInterpolator()); } result.addAnimation(drop); return result; }
From source file:com.devbrackets.android.exomedia.DefaultControls.java
/** * Performs the control visibility animation for showing or hiding * this view/*from ww w.j av a 2 s . c om*/ * * @param toVisible True if the view should be visible at the end of the animation */ private void animateVisibility(boolean toVisible) { if (isVisible == toVisible) { return; } float startAlpha = toVisible ? 0 : 1; float endAlpha = toVisible ? 1 : 0; AlphaAnimation animation = new AlphaAnimation(startAlpha, endAlpha); animation.setDuration(CONTROL_VISIBILITY_ANIMATION_LENGTH); animation.setFillAfter(true); startAnimation(animation); isVisible = toVisible; onVisibilityChanged(); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Add an action to set the alpha of a view. Can be called multiple times. * Alpha between 0-1.//from ww w.ja v a2s . co m */ public BaseAdapterHelper setAlpha(int viewId, float value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { retrieveView(viewId).setAlpha(value); } else { // Pre-honeycomb hack to set Alpha value AlphaAnimation alpha = new AlphaAnimation(value, value); alpha.setDuration(0); alpha.setFillAfter(true); retrieveView(viewId).startAnimation(alpha); } return this; }
From source file:com.numix.calculator.EventListener.java
private void deleteAnimation(View view) { final TextView colorLayout = (TextView) view.getRootView().findViewById(R.id.deleteColor); final LinearLayout displayView = (LinearLayout) view.getRootView().findViewById(R.id.displayLayout); final CalculatorDisplay calculatorDisplay = (CalculatorDisplay) view.getRootView() .findViewById(R.id.display); int finalRadius = Math.max(displayView.getWidth(), displayView.getHeight()); // create the animator for this view (the start radius is zero) Animator colorAnim;//from w ww. j ava 2 s .c om colorAnim = ViewAnimationUtils.createCircularReveal(colorLayout, (int) displayView.getRight(), (int) displayView.getBottom(), 0, finalRadius); final AlphaAnimation fadeAnim = new AlphaAnimation(1.0f, 0.0f); final AlphaAnimation fadeDisplay = new AlphaAnimation(1.0f, 0.0f); fadeAnim.setDuration(250); fadeAnim.setInterpolator(new AccelerateInterpolator()); fadeAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { colorLayout.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) { } }); fadeDisplay.setDuration(250); fadeDisplay.setInterpolator(new AccelerateInterpolator()); fadeDisplay.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mHandler.onClear(); displayView.setAlpha(1.0f); } @Override public void onAnimationRepeat(Animation animation) { } }); colorAnim.setInterpolator(new AccelerateInterpolator()); colorAnim.addListener(new android.animation.Animator.AnimatorListener() { @Override public void onAnimationStart(android.animation.Animator animation) { calculatorDisplay.startAnimation(fadeDisplay); } @Override public void onAnimationRepeat(android.animation.Animator animation) { } @Override public void onAnimationEnd(android.animation.Animator animation) { colorLayout.startAnimation(fadeAnim); } @Override public void onAnimationCancel(android.animation.Animator animation) { } }); colorLayout.setVisibility(View.VISIBLE); colorAnim.start(); }
From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java
/** * Create dynamically an android animation for a coin or a bill deleted from * the moneybox.//from w w w .j a v a2s. com * * @param img * ImageView to receive the animation * @param layout * Layout that paint the image * @return Set of animations to apply to the image */ private AnimationSet createDeleteAnimation(ImageView img, View layout) { AnimationSet result; result = new AnimationSet(false); result.setFillAfter(true); // Fade out AlphaAnimation fadeOut; fadeOut = new AlphaAnimation(1.0f, 0.0f); fadeOut.setStartOffset(300); fadeOut.setDuration(300); result.addAnimation(fadeOut); return result; }
From source file:com.example.camera360.ui.ImageDetailActivity.java
private void showDetailView(final float p1, final float p2) { AlphaAnimation alphaAnimation = new AlphaAnimation(p1, p2); alphaAnimation.setDuration(DURATION_MILLIS); alphaAnimation.setAnimationListener(new AnimationListener() { @Override// w w w . jav a 2 s . co m public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mImageDetailView.clearAnimation(); if (p2 == 0) { mImageDetailView.setVisibility(View.INVISIBLE); } checkStatus(); } }); mImageDetailView.setAnimation(alphaAnimation); alphaAnimation.setFillAfter(true); }
From source file:com.mina.breathitout.AnalyzeActivity.java
private void moveUp() { AnalyzeActivity.this.runOnUiThread(new Runnable() { @Override/*w w w . j a v a 2 s .co m*/ public void run() { view.moveUP(); breathOutView.setVisibility(View.VISIBLE); AlphaAnimation fadeIn_breathout = new AlphaAnimation(0.0f, 1.0f); fadeIn_breathout.setDuration(2000); fadeIn_breathout.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { AlphaAnimation fadeOut_breathout = new AlphaAnimation(1.0f, 0.0f); breathOutView.startAnimation(fadeOut_breathout); fadeOut_breathout.setDuration(2000); breathOutView.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); breathOutView.startAnimation(fadeIn_breathout); fadeIn_breathout.setFillAfter(true); animateProgressBar(); } }); }
From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java
@Override public void onSingleTap() { if (headerBar.getVisibility() == View.VISIBLE) { AlphaAnimation animation = new AlphaAnimation(1, 0); animation.setDuration(300); headerBar.startAnimation(animation); headerBar.setVisibility(View.GONE); } else {//www . ja va2 s . co m headerBar.setVisibility(View.VISIBLE); AlphaAnimation animation = new AlphaAnimation(0, 1); animation.setDuration(300); headerBar.startAnimation(animation); } }
From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java
private void hideViewPager() { pagerContainer.setVisibility(View.GONE); gridView.setVisibility(View.VISIBLE); findViewById(FakeR.getId(this, "id", "album_title_bar")).setVisibility(View.VISIBLE); AnimationSet set = new AnimationSet(true); ScaleAnimation scaleAnimation = new ScaleAnimation(1, (float) 0.9, 1, (float) 0.9, pagerContainer.getWidth() / 2, pagerContainer.getHeight() / 2); scaleAnimation.setDuration(200);// w w w . j a va 2 s.c o m set.addAnimation(scaleAnimation); AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0); alphaAnimation.setDuration(200); set.addAnimation(alphaAnimation); pagerContainer.startAnimation(set); ((BaseAdapter) gridView.getAdapter()).notifyDataSetChanged(); }
From source file:io.github.data4all.activity.CameraActivity.java
private AlphaAnimation createAnimation(final View v) { AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(3000); anim.setStartOffset(3000);/* w w w .j a v a 2 s .c o m*/ anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.INVISIBLE); v.setClickable(false); } @Override public void onAnimationRepeat(Animation animation) { } }); return anim; }