Android examples for User Interface:View Animation
Stars a loading animation for the specified view.
//package com.java2s; import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; public class Main { /**/* w w w . j a v a 2 s . c o m*/ * Stars a loading animation for the specified view. * * @param v * the view to animate */ public static void animateLoading(View v) { showView(v); AlphaAnimation loadingAnim = new AlphaAnimation(1F, 0.0F); loadingAnim.setDuration(800); loadingAnim.setFillAfter(false); loadingAnim.setRepeatMode(Animation.REVERSE); loadingAnim.setRepeatCount(Animation.INFINITE); v.startAnimation(loadingAnim); } /** * 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); } } }