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?
A:
One method for this would be to use the animation set. See here;
http://developer.android.com/guide/topics/resources/available-resources.html#animation
Some example code I have done (infinite loop fade out in this example) ;
In the animation .xml file;
< alpha
android:fromAlpha="1.0"
android:toAlpha="0.3"
android:duration="7000"
android:repeatMode="restart"
android:repeatCount="infinite"/>
In the java file;
ImageView introanim = (ImageView) findViewById(R.id.introanim);
Animation StoryAnimation = AnimationUtils.loadAnimation(this, R.anim.intro_anim);
introanim.startAnimation(StoryAnimation);
You could fade from your sepia background/picture to whatever you want...
Mike Droid
2010-04-08 15:09:27
Thanks Jorge and Mike. I'll try your ways of doing.
Hiroshi Iwatani
2010-04-09 12:34:06
+1
A:
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" android:repeatCount="infinite"/>
</set>
but for the gradual fade in from sepia to the full color, you must use TransitionDrawable
Jorgesys
2010-04-08 16:40:39