Android examples for User Interface:View Fade
Fades the specified view in slowly.
//package com.java2s; import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.AnimationSet; import android.view.animation.OvershootInterpolator; import android.view.animation.ScaleAnimation; public class Main { /**//from w ww .java2 s . c o m * Fades the specified view in slowly. * * @param v * the view to fade in */ public static void progressfadeIn(View v) { showView(v); AnimationSet set = new AnimationSet(false); ScaleAnimation scaleIn = new ScaleAnimation(0.1f, 1, 0.1f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleIn.setFillAfter(true); scaleIn.setStartOffset(500); scaleIn.setDuration(500); scaleIn.setInterpolator(new OvershootInterpolator()); AlphaAnimation fadeIn = new AlphaAnimation(0F, 1F); fadeIn.setDuration(2000); fadeIn.setFillAfter(false); set.addAnimation(scaleIn); set.addAnimation(fadeIn); v.startAnimation(set); } /** * Shows the specified view if invisible or gone. * * @param v * the view to show */ public static void showView(View v) { if (v.getVisibility() == View.INVISIBLE || v.getVisibility() == View.GONE) { v.setVisibility(View.VISIBLE); } } }