Set View Alpha animation - Android User Interface

Android examples for User Interface:View Animation

Description

Set View Alpha animation

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;

import android.os.Build;
import android.view.View;
import android.view.animation.AlphaAnimation;

public class Main {
    @SuppressLint("NewApi")
    public static void SetAlpha(View view, float alpha) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            view.setAlpha(alpha);//from   w w w . j av  a 2  s . co  m
        } else {
            AlphaAnimation a = new AlphaAnimation(alpha, alpha);
            a.setDuration(0);
            a.setFillAfter(true);
            view.startAnimation(a);
        }
    }
}

Related Tutorials