Hi Satish,

Animation between activities is indeed possible in Android 2.0 and
later, using the overridePendingTransition() API, with the caveat as
implied by Sean, that the user can override the animations if he so
wishes, in his global device settings.  This API was specifically
added to give developers more control over inter-activity animations
(versus view animations which are done intra-activity).

I posted a tutorial on exactly how to use overridePendingTransition()
at anddev.org:
    http://www.anddev.org/viewtopic.php?p=32766

Though the tutorial shows a fade transition between two activities, it
can easily be changed to do a diagonal transition, as per your OP: "In
my case the user should get the feel that next screen is coming from
one corner of the current screen."  Here is how:

In the tutorial, replace mainfadein.xml with diagslide_enter.xml:

    <?xml version="1.0" encoding="utf-8"?>
        <translate xmlns:android="http://schemas.android.com/apk/res/
android"
           android:fromXDelta="-100%" android:toXDelta="0%"
            android:fromYDelta="-100%" android:toYDelta="0%"
            android:duration="2000" />

and replace splashfadeout.xml with diagslide_leave.xml:

    <?xml version="1.0" encoding="utf-8"?>
        <translate xmlns:android="http://schemas.android.com/apk/res/
android"
            android:fromXDelta="0%" android:toXDelta="-100%"
            android:fromYDelta="0%" android:toYDelta="-100%"
            android:duration="2000" />

Add diagslide_enter.xml and diagslide_leave.xml to your /res/anim
directory, and change
the overridePendingTransition() statement to:

    overridePendingTransition(R.anim.diagslide_enter,
R.anim.diagslide_leave);

This will give the feel of the next screen coming from one corner,
while the previous screen leaves from the other corner.

Here's a YouTube video (forgive the quality, the emulator runs
horribly slowly on my system, but it looks terrific on the Droid):
    http://www.youtube.com/watch?v=vqTbdAg_82c

If you'd rather have the next screen come from one corner, while the
previous screen stays put, do this:

    overridePendingTransition(R.anim.diagslide_enter, R.anim.hold);

where hold.xml is a placeholder to keep the old activity from
disappearing too soon:

    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/
android"
       android:fromXDelta="0" android:toXDelta="0"
       android:duration="2000" />

If you'd rather have the next screen come from one corner over an
empty background, do this:

    overridePendingTransition(R.anim.diagslide_enter, 0);

Once you get it working you should probably consider shortening the
durations, 2 seconds is kind of long.

Great info on other animation attributes is here:
    
http://developer.android.com/intl/zh-CN/guide/topics/resources/available-resources.html#animation

There are examples in the SDK (search *.java in the 2.X platforms for
overridePendingTransition).

I will add some of this info to the anddev tutorial, and post a
trackback.

Hope this helps!
XCaf



On Jan 8, 7:55 am, satish bhoyar <getsatonl...@gmail.com> wrote:
> Hi,
> I am trying to do the diagonal screen transition, & i am not able to figure
> out what I should use. In my case the user should get the feel that next
> screen is coming from one corner of the current screen .
>
> Thanks,
-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to