r/androiddev • • Jun 09 '17

Article Implementing Complex Animations in Android (Full Working Code)

https://medium.com/p/implementing-complex-animations-in-android-full-working-code-41979cc2369e
212 Upvotes

12 comments sorted by

12

u/CodyEngel Jun 09 '17

Really excited for this article though one pet peeve: you say full working code but omit the first example as an exercise for developers. It would have been really nice to have the full working code for all of these examples (granted I haven't finished reading the article yet, that's just my impression after reading the intro).

-4

u/wajee Jun 09 '17 edited Jun 09 '17

Sorry about confusion. Here meaning of full working code was that instead of just code snippets, a github project is also available. First animation can be implemented using shared element transition with a transparent activity. I havn't tried it but thats how I would do it.

4

u/MikeOscarEcho Jun 09 '17

Would be cool if there was a full working example as part of the source code either way. You could have two modules, one with the partial examples where a developer can try and implement the ShareElementTransition and one with the full working code sample.

Either way, thank you!

0

u/[deleted] Jun 09 '17

[deleted]

3

u/wajee Jun 09 '17

For making activity transparent use this theme:

<style name="AppTheme.NoActionBar.Transparent">
    <item name="android:windowAnimationStyle">@null</item>
    <item name="android:background">@android:color/transparent</item>
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
</style>

Then once its launched, you can play with layout's background.

For your second question:

I cannot possibly start with visibility=gone, then start my animation which also sets visibility=visible at the same time

Thats exactly what I would do and you can find such examples in Android's OS code as well e.g check this out

https://android.googlesource.com/platform/packages/apps/PhoneCommon/+/lollipop-release/src/com/android/phone/common/animation/AnimUtils.java

Basically change visibility/alpha and once animation is started, show your view.

78

u/drabred Jun 09 '17

It's all fun and games when you have minSdk 21 :)

4

u/CharaNalaar Jun 10 '17

Ugh, how I wish I could do the same.

2

u/arunkumar9t2 Jun 10 '17

I did for 2 of my apps. Not regretting it.

3

u/gonemad16 GoneMAD Software Jun 10 '17

not having to worry about prelollipop devices is so nice.. i dont regret switching to minSdk 21 at all

1

u/BacillusBulgaricus ComposableThermosiphon Jun 10 '17

Me too. I highly recommend minSDK 21. For me that's the first really solid version.

15

u/coolmyll Jun 09 '17

First one seems really cool but no example for that.

1

u/vanhoa Jun 10 '17

can use fragment to make the effect like Shared Element Transitions in pre lollipop?

1

u/[deleted] Jun 10 '17

Ha I'd give up and switch to Flutter!

(Not actually; it's definitely still "alpha" quality.)