500px / 500px-android-blur

Android Blurring View
http://developers.500px.com/2015/03/17/a-blurring-view-for-android.html
MIT License
2.69k stars 326 forks source link

I found I could animate alpha from 1 to 0 but not from 0 to 1. #6

Closed rw86347 closed 9 years ago

rw86347 commented 9 years ago

I really really want to thank you for this. This is exactly what I needed however I can't seem to animate alpha from 0 to 1.

This code can fit directly into your sample to show you the problem.

public void shuffle(View view) { final AlphaAnimation animation1 = new AlphaAnimation(0.1f, 1.0f); animation1.setDuration(1000); animation1.setStartOffset(1000);

    animation1.setAnimationListener(new Animation.AnimationListener() {

        @Override
        public void onAnimationEnd(Animation arg0) {
            blurrHolder.invalidate();
            blurrHolder.setAlpha((float) 1);
        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
            blurrHolder.invalidate();
        }

        @Override
        public void onAnimationStart(Animation arg0) {
            blurrHolder.invalidate();
        }
    });

    mBlurringView.startAnimation(animation1);
}
luojun commented 9 years ago

Hard for me to tell. But maybe what's said here is relevant: http://stackoverflow.com/questions/11386953/alphaanimation-does-not-work ? In other words, maybe we need to ensure that the view's alpha is non zero when animation starts?