Material Design Hub

Thursday, May 28, 2015

Material Animations Android Library

4:53 PM

Android Transition animations explanation with examples.

Min SDK:- 16 (Android 4.1 Jelly Bean)

Author:-  https://github.com/lgvalle/Material-Animations/graphs/contributors

Description:- 
Android Transitions
android Transition Framework can be used for three main things:

1: Animate View elements in transitions between activites (or fragments)
2: Animate shared elements (hero views) in transitions between activities (or fragments)
Animate View elements from one activity scene to another.

1. Transitions between Activities


Animate existing activity layout content (non-hero views)
Material Animations Android Library

Click Here for Download Material Animations Android Library

How to use Material Animations Android Library in eclipse :-

Step 1: Create a new Android Project

Step 2: Import  Library to your Android Application Project
     1: File->New->Other
     2: Select Android Project
     3: Select "Create Project from existing source"
     4: Click "Browse and select Material Animations Android Library, 
     5: Finish 
     6: Right-click on your project -> Properties
     7: In Android->Library section click Add
     8: select recently added project -> Ok
     9: that's it!

Declarative:-


res/transition/activity_explode.xml
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <explode android:duration="2000"/>
</transitionSet>
res/values/style.xml
<item name="android:windowEnterTransition">@transition/activity_explode.xml</item>
To inflate specific xml defined transition:
MainActivity.java
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupWindowAnimations();
    }

    private void setupWindowAnimations() {
        Explode explode = TransitionInflater.from(this).inflateTransition(R.transition.activity_explode);
        explode.setDuration(2000);
        getWindow().setExitTransition(explode);
    }

Programatically

MainActivity.java
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupWindowAnimations();
    }

    private void setupWindowAnimations() {
        Explode explode = new Explode();
        explode.setDuration(2000);
        getWindow().setExitTransition(explode);
    }
DetailActivity.java
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setupWindowAnimations();
    }

    private void setupWindowAnimations() {
        Explode explode = new Explode();
        explode.setDuration(2000);
        getWindow().setEnterTransition(explode);
    }
Material Animations Android Library



Click Here for more details of implementation:

Please Join our Facebook  Group and Page

Facebook group: Android controls

Facebook page: Android Controls

Subscribe YouTube channel: Click here

SUBSCRIBE TO OUR EMAIL NEWSLETTER & RECEIVE UPDATES RIGHT IN YOUR INBOX.   Click here


If You Have Any question or Suggestions Please Feel Free to Comments .

0 comments