Discussion Forums  >  Suggestions, Ideas, Wish List

Replies: 12    Views: 1514

feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
06/03/13 02:32 PM (12 years ago)

Android Screen Transitions

Hello Again Im dying for some android screen transitions. I know we there is nothing as fun as IOS transitions, but it would be nice for some android screen transitions. Does anyone out there have any special code snippet for android screen transitions? I love the android screen transition that vertically flips.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/03/13 02:48 PM (12 years ago)
Hi @feraco, loads of code snippets on the net, I use a few in the quiz app in my profile. Here's a zoom in/zoom out example: Create a file in your 'anim' folder (in the res folder) called zoom_in.xml and add this code to the file: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <scale android:fromXScale="0.0" android:toXScale="1.0" android:fromYScale="0.0" android:toYScale="1.0" android:pivotX="50%p" android:pivotY="50%p" android:duration="1200" /> </set> Create a zoom_out.xml file too: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator" android:zAdjustment="top"> <scale android:fromXScale="1.0" android:toXScale=".5" android:fromYScale="1.0" android:toYScale=".5" android:pivotX="50%p" android:pivotY="50%p" android:duration="1200" /> <alpha android:fromAlpha="1.0" android:toAlpha="0" android:duration="1200"/> </set> In the activity where you want to use the transition add: overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out) In the onCreate method, just after the layout inflator, so it looks like this: //inflate this screens layout file... LayoutInflater vi = (LayoutInflater)thisActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); thisScreensView = vi.inflate(R.layout.screen_quiz, null); overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out); That's it.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
06/04/13 08:36 AM (12 years ago)
O Great! Im trying this now. Thank you. Where did you find this?
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/04/13 09:05 AM (12 years ago)
All paths lead from stackoverflow.com lol! I'll get back to you on that. I know there are some examples on the android developer site and there's a compatibility library on github called nineoldandroids for pre-honeycomb animations which is very cool. I'll dig out some links and post back later.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
06/04/13 09:09 AM (12 years ago)
Your the best thank you so much! Ill search to check it out.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/04/13 10:28 AM (12 years ago)
haha! no problem @feraco. Here are some links: About animations + some code examples http://developer.android.com/guide/topics/graphics/view-animation.html fade in/fade out http://stackoverflow.com/a/5145226 left to right http://stackoverflow.com/a/5151774 grow from middle/shrink to middle http://stackoverflow.com/a/8570948 The above examples are used the same way as I posted above, nineoldandroids is different but pretty straightforward. http://nineoldandroids.com/ I've got a list of links somewhere, I can't find it... If I do, I'll post it.
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/06/13 04:34 AM (12 years ago)
Hi feraco, any joy with the transitions?
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
06/06/13 04:47 AM (12 years ago)
Yes Those transitions are very nice. right now im using the zoom in zoom out for all screens it works great! I saw an android app that has a really cool screen flip from up to down. but you had to pull it, like a page curl. I dont know how to describe it more than that. Have you seen this?
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/06/13 05:34 AM (12 years ago)
Excellent! I think I know what you mean, I'm sure I've seen something similar on stackoverflow, haven't tried it though, it looks complicated! Ontouchlisteners and stuff.. I've got a bounce transition that you might like? The screen drops down from the top and bounces a couple of times when it hits the bottom. bounce.xml in the anim folder: <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/bounce_interpolator"> <translate android:fromYDelta="-100%p" android:toYDelta="0" android:duration="2000"/> </set> code in the onCreate: overridePendingTransition(R.anim.bounce, R.anim.bounce);
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
06/06/13 09:42 AM (12 years ago)
Hey the app is called flipbook for android. Im looking on the stackoverflow now it has a really cool transition.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
06/06/13 09:46 AM (12 years ago)
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
06/06/13 10:34 AM (12 years ago)
Not a chance! lol! Just tried now, can't even get the demo running. It's a heck of a lot of code just to flip pages. Would be cool though.. The library's running ok, I'll take a longer look later, but I think it'll take too much modifying of bt screens. In fact, I think it uses fragments which bt don't support yet, although in a few weeks that might have changed.
 
feraco
Aspiring developer
Profile
Posts: 705
Reg: Jan 23, 2012
nyc
15,050
like
09/05/13 12:39 PM (12 years ago)
How do we create screen transitions with the new android core?
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.