views:

97

answers:

1

I have a widget which starts an activity when it is clicked. I'd like to have some kind of fancy animation to display this activity, rather than the standard scroll-from-right of Android. I'm having problems setting it, though. This is what I have:

slide_top_to_bottom.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromYDelta="-100%" android:toXDelta="0" android:duration="100" />
    <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="50" />
</set>

...which is referenced in anim.xml

<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
        android:delay="50%"
        android:animation="@anim/slide_top_to_bottom" />

But then where do I reference it from? I've tried both the base element of the activity I want to slide in, and the activitiy's entry in the manifest, both times with

android:layoutAnimation="@+anim/anim"

I might be doing this all wrong. Any help is much appreciated!

A: 
startActivity(intent);
overridePendingTransition(R.anim.slide_top_to_bottom, R.anim.hold);

Check this link: overridePendingTransition method

Edit:

To Achieve the Animation for the Views. You have use the startAnimation Method like below

view.startAnimation(AnimationUtils.loadAnimation(
                 WidgetActivity.this,R.anim.slide_top_to_bottom));

Check this link:

Praveen Chandrasekaran
I'm starting the activity from a widget, so I don't have a startActivity() but rather a setOnClickPendingIntent(). Where would I have the call to overridePendingTransition()?Edit: That's also for 2.0 and up, I'm targeting 1.6+
blork
Start Animation method. we have to use. Check the ApiDemos. It helps.
Praveen Chandrasekaran