Example usage for android.view.animation AlphaAnimation AlphaAnimation

List of usage examples for android.view.animation AlphaAnimation AlphaAnimation

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation AlphaAnimation.

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:Main.java

public static void fadeIn(final View view, AnimationListener animationListener, int duration) {
    Animation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setAnimationListener(animationListener);
    view.startAnimation(alphaAnimation);
}

From source file:Main.java

public static AlphaAnimation getAlphaAnimation(float fromAlpha, float toAlpha, long durationMillis,
        AnimationListener animationListener) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(durationMillis);
    if (animationListener != null) {
        alphaAnimation.setAnimationListener(animationListener);
    }//ww w .j  a  v a 2  s.c o  m
    return alphaAnimation;
}

From source file:Main.java

public static Animation getFadeInAnimation(int durationInMilliseconds) {
    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setFillAfter(true);//  ww  w. j av  a2s.c  o  m
    fadeIn.setInterpolator(new AccelerateInterpolator());
    fadeIn.setDuration(durationInMilliseconds);
    return fadeIn;
}

From source file:Main.java

@SuppressWarnings("IfCanBeSwitch")
private static Animation createAnimationFromXml(Context c, XmlPullParser parser, AnimationSet parent,
        AttributeSet attrs) throws XmlPullParserException, IOException {

    Animation anim = null;/*  ww  w  .  j  a  v a2 s  .c o  m*/

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        String name = parser.getName();

        if (name.equals("set")) {
            anim = new AnimationSet(c, attrs);
            createAnimationFromXml(c, parser, (AnimationSet) anim, attrs);
        } else if (name.equals("alpha")) {
            anim = new AlphaAnimation(c, attrs);
        } else if (name.equals("scale")) {
            anim = new ScaleAnimation(c, attrs);
        } else if (name.equals("rotate")) {
            anim = new RotateAnimation(c, attrs);
        } else if (name.equals("translate")) {
            anim = new TranslateAnimation(c, attrs);
        } else {
            throw new RuntimeException("Unknown animation name: " + parser.getName());
        }

        if (parent != null) {
            parent.addAnimation(anim);
        }
    }

    return anim;

}

From source file:de.uni_weimar.m18.anatomiederstadt.SplashActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    final PathView pathView = (PathView) findViewById(R.id.pathView);
    pathView.useNaturalColors();//from   ww  w . ja v a2s.  c o m

    int pathDelay = 1000;
    int pathDuration = 2500;

    final Animation a = new AlphaAnimation(0.00f, 1.00f);
    a.setStartOffset(3500);
    a.setDuration(1000);

    //pathView.setSvgResource(R.raw.vitruvian_man_weimar_kk3);
    pathView.getPathAnimator().delay(pathDelay).duration(pathDuration)
            .interpolator(new AccelerateDecelerateInterpolator()).start();

    final ImageView logoImage = (ImageView) findViewById(R.id.logoImage);

    a.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            logoImage.setVisibility(View.VISIBLE);

            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    launchMainActivity();
                }
            }, 1500);

        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    logoImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            launchMainActivity();
        }
    });

    logoImage.startAnimation(a);

}

From source file:com.todoroo.astrid.helper.ProgressBarSyncResultCallback.java

@Override
public void finished() {
    if (providers.decrementAndGet() == 0) {
        activity.runOnUiThread(new Runnable() {
            @Override/*  w  ww  .j  a v  a 2 s  . c o  m*/
            public void run() {
                try {
                    progressBar.setMax(100);
                    progressBar.setProgress(100);
                    AlphaAnimation animation = new AlphaAnimation(1, 0);
                    animation.setFillAfter(true);
                    animation.setDuration(1000L);
                    progressBar.startAnimation(animation);

                    onFinished.run();
                } catch (Exception e) {
                    // ignore, view could have been destroyed
                }
            }
        });
        new Thread() {
            @Override
            public void run() {
                AndroidUtilities.sleepDeep(1000);
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            progressBar.setVisibility(View.GONE);
                        } catch (Exception e) {
                            // ignore
                        }
                    }
                });
            }
        }.start();
    }
}

From source file:com.devbrackets.android.exomedia.ui.animation.TopViewHideShowAnimation.java

public TopViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);

    //Creates the Translate animation for the transition
    int startY = toVisible ? -view.getHeight() : 0;
    int endY = toVisible ? 0 : -view.getHeight();
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, startY, endY);
    translateAnimation//from   w ww .j  a  v  a 2  s  . c  om
            .setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);

    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}

From source file:com.devbrackets.android.exomedia.ui.animation.BottomViewHideShowAnimation.java

public BottomViewHideShowAnimation(View view, boolean toVisible, long duration) {
    super(false);
    this.toVisible = toVisible;
    this.animationView = view;

    //Creates the Alpha animation for the transition
    float startAlpha = toVisible ? 0 : 1;
    float endAlpha = toVisible ? 1 : 0;

    AlphaAnimation alphaAnimation = new AlphaAnimation(startAlpha, endAlpha);
    alphaAnimation.setDuration(duration);

    //Creates the Translate animation for the transition
    int startY = toVisible ? getHideShowDelta(view) : 0;
    int endY = toVisible ? 0 : getHideShowDelta(view);
    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, startY, endY);
    translateAnimation/*from w w  w .  j  a va  2  s  . co m*/
            .setInterpolator(toVisible ? new LinearOutSlowInInterpolator() : new FastOutLinearInInterpolator());
    translateAnimation.setDuration(duration);

    //Adds the animations to the set
    addAnimation(alphaAnimation);
    addAnimation(translateAnimation);

    setAnimationListener(new Listener());
}

From source file:com.nikola.despotoski.drawerlayouttoggles.FadingDrawerToggle.java

@SuppressLint("NewApi")
@Override//  www  .  j ava2  s  . c  om
public void onDrawerSlide(View drawerView, float slideOffset) {
    if (!mEnabled)
        return;
    float currentViewAlpha = slideOffset * MAX_VIEW_ALPHA;
    float currentDrawableAlpha = slideOffset * MAX_DRAWABLE_ALPHA;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        drawerView.setAlpha(currentViewAlpha);
    } else {
        AlphaAnimation alphaAnimation = new AlphaAnimation(mPreviousViewAlpha, currentViewAlpha);
        alphaAnimation.setFillAfter(true);
        alphaAnimation.setDuration(0);
        drawerView.startAnimation(alphaAnimation);
        mPreviousViewAlpha = currentViewAlpha;
    }
    drawerView.getBackground().setAlpha((int) currentDrawableAlpha);

}

From source file:org.wheelmap.android.utils.ViewTool.java

public static void setAlphaForView(View alphaView, float alpha) {

    AlphaAnimation animation = new AlphaAnimation(alpha, alpha);

    animation.setDuration(0);//  w w  w  .  jav a  2s.  c o  m
    animation.setFillAfter(true);

    alphaView.startAnimation(animation);
}