public static void animate(View v, int duration) { AlphaAnimation alpha = new AlphaAnimation(0f, 1f); alpha.setDuration(duration); v.startAnimation(alpha); } }
/** * Animates {@link ImageView} with "fade-in" effect * * @param imageView {@link ImageView} which display image in * @param durationMillis The length of the animation in milliseconds */ public static void animate(View imageView, int durationMillis) { if (imageView != null) { AlphaAnimation fadeImage = new AlphaAnimation(0, 1); fadeImage.setDuration(durationMillis); fadeImage.setInterpolator(new DecelerateInterpolator()); imageView.startAnimation(fadeImage); } } }
AlphaAnimation alpha = new AlphaAnimation(0.5F, 0.5F); alpha.setDuration(0); // Make animation instant alpha.setFillAfter(true); // Tell it to persist after the animation ends // And then on your layout yourLayout.startAnimation(alpha);
private static void setAlpha(View view, float alpha) { // Set the alpha appropriately (setAlpha is API >= 11, this technique works on all API levels). AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha); alphaAnimation.setDuration(0); alphaAnimation.setFillAfter(true); view.startAnimation(alphaAnimation); }
AlphaAnimation alpha = new AlphaAnimation(0.7F, 0.7F); alpha.setDuration(0); // Make animation instant alpha.setFillAfter(true); // Tell it to persist after the animation ends view.startAnimation(alpha);
if (Build.VERSION.SDK_INT < 11) { final AlphaAnimation animation = new AlphaAnimation(alpha, alpha); animation.setDuration(duration); animation.setFillAfter(true); view.startAnimation(animation); } else view.setAlpha(alpha); }
AlphaAnimation alpha = new AlphaAnimation(0.7F, 0.7F); alpha.setDuration(0); // Make animation instant alpha.setFillAfter(true); // Tell it to persist after the animation ends view.startAnimation(alpha);
private void setupAnimations() { fadeInAnimation = new AlphaAnimation(0.0f, 1.0f); fadeInAnimation.setDuration(300); fadeInAnimation.setInterpolator(new AccelerateInterpolator()); fadeInAnimation.setAnimationListener(this); fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f); fadeOutAnimation.setDuration(300); fadeOutAnimation.setInterpolator(new AccelerateInterpolator()); fadeOutAnimation.setAnimationListener(this); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static void applyAlphaAnimation(View view, float alpha) { if (isPostHoneycomb()) { view.setAlpha(alpha); } else { AlphaAnimation alphaAnimation = new AlphaAnimation(alpha, alpha); // make it instant alphaAnimation.setDuration(0); alphaAnimation.setFillAfter(true); view.startAnimation(alphaAnimation); } }
private static void setAlpha(View view, float alphaValue){ if(alphaValue == 1){ view.clearAnimation(); }else{ AlphaAnimation alpha = new AlphaAnimation(alphaValue, alphaValue); alpha.setDuration(0); // Make animation instant alpha.setFillAfter(true); // Tell it to persist after the animation ends view.startAnimation(alpha); } }
AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f); animation1.setDuration(1000); animation1.setStartOffset(5000); animation1.setFillAfter(true); iv.startAnimation(animation1)
public BaseViewHolder setAlpha(int viewId, float value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getView(viewId).setAlpha(value); } else { AlphaAnimation alpha = new AlphaAnimation(value, value); alpha.setDuration(0); alpha.setFillAfter(true); getView(viewId).startAnimation(alpha); } return this; }
@Override public EasyLVHolder setAlpha(int viewId, float value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getView(viewId).setAlpha(value); } else { AlphaAnimation alpha = new AlphaAnimation(value, value); alpha.setDuration(0); alpha.setFillAfter(true); getView(viewId).startAnimation(alpha); } return this; }
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(1000); anim.setRepeatCount(NUM_REPEATS); anim.setRepeatMode(Animation.REVERSE); button.startAnimation(anim);
@Override public EasyRVHolder setAlpha(int viewId, float value) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getView(viewId).setAlpha(value); } else { AlphaAnimation alpha = new AlphaAnimation(value, value); alpha.setDuration(0); alpha.setFillAfter(true); getView(viewId).startAnimation(alpha); } return this; }
/** * Fade in */ public void fadeIn() { AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f); anim.setDuration(200); startAnimation(anim); setVisibility(VISIBLE); // focus on the view requestFocus(); }
/** * Fade out */ public void fadeOut() { if(getVisibility() == GONE) return; AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(200); startAnimation(anim); setVisibility(GONE); } }
@Override public void initView() { StatusBarUtil.setColor(this, UIUtils.getColor(R.color.black)); AlphaAnimation alphaAnimation = new AlphaAnimation(0, 1); alphaAnimation.setDuration(1000); mRlButton.startAnimation(alphaAnimation); }
@Bus(EventTags.FLASH_INIT_UI) public void initUI() { AlphaAnimation anim = new AlphaAnimation(0.8f, 0.1f); anim.setDuration(5000); mViewBinding.view.startAnimation(anim); AnimationUtil.setAnimationListener(anim, () -> OkBus.getInstance().onEvent(EventTags.JUMP_TO_MAIN)); }
/** * Fade out */ public void fadeOut() { AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(200); startAnimation(anim); setVisibility(GONE); // fix onclick issue clearFocus(); setClickable(false); }