I am starting an activity and would rather have a alpha fade-in for startActivity()
, and a fade-out for the finish()
. How can I go about this in the Android SDK?
views:
180answers:
2
A:
see themes on android, http://developer.android.com/guide/topics/ui/themes.html and under http://goo.gl/zOlL there should be android:windowAnimationStyle where you can see the declaration of the style in http://goo.gl/MmE8
monmonja
2010-08-18 18:21:32
A:
In the same statement you execute finish, execute your animation there to. Then in the new activity your run another animation. See this code:
fadein.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="500"/> //Time in milliseconds
</set>
In your finish-class
if(blabbla==blablabla){
finish();
runFadeAnimation();
}
private void runFadeInAnimation() {
Animation a = AnimationUtils.loadAnimation(this, R.anim.fadein);
a.reset();
LinearLayout ll = (LinearLayout) findViewById(R.id.yourviewhere);
ll.clearAnimation();
ll.startAnimation(a);
}
fadeout.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500"/>
</set>
In your new Activity-class you create a similiar method like the runFadeAnimation I wrote and then you run it in onCreate and don't forget to change the resources id to fadeout.
Julian Assange
2010-08-18 18:55:29