Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a fadein of an image on an Android Activity screen?

I'd like to display a photo on an Android Activity screen with doing gradual and continual fade-in from pale monotone sepia to the final full color. I know how to do it on a Java Image/BufferedImage for the Graphic object but unfortunately I know nothing for the Android programming environment. Could anyone help?

like image 379
Hiroshi Iwatani Avatar asked Apr 08 '10 03:04

Hiroshi Iwatani


People also ask

What is Fade in android?

In Android Animations are the visuals that are added to make the user interface more interactive, clear and good looking. Fade In and Fade out animations are used to modify the appearance of any view over a set interval of time so that user can be notified about the changes that are occurring in our application.

How to create Animation programmatically in android?

setListener(new Animator. AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }). start();


1 Answers

Hi Hiroshi you can do this for the fade in:

  ImageView myImageView= (ImageView)findViewById(R.id.myImageView);   Animation myFadeInAnimation = AnimationUtils.loadAnimation(this, R.anim.fadein);   myImageView.startAnimation(myFadeInAnimation); //Set animation to your ImageView 

and inside your res\anim\ folder the animation file fadein.xml

<?xml version="1.0" encoding="UTF-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android">         <alpha              android:fromAlpha="0.0"              android:toAlpha="1.0"             android:interpolator="@android:anim/accelerate_interpolator"             android:duration="3000"/> </set> 

but for the gradual fade in from sepia to the full color, you must use TransitionDrawable

like image 59
Jorgesys Avatar answered Oct 06 '22 01:10

Jorgesys