Download Code

Material Design Custom Animation Android

Material Design is a new strategy to Design android applications.It was introduced in Android Lollipop.Material Design includes Material Theme,custom Animation etc.In material design custom animation android tutorial you will learn how to use Material Design Structure by customizing theme,will use Material design custom animation upon new activity startup etc.

Let me first give you some introduction about customizing the Theme with Material Design.There are some theme attributes when you inherit from Material Theme.

  • colorPrimaryDark : Color apply on notification bar background.
  • colorPrimary : Color apply on Action Bar(Toolbar) Background.
  • textColorPrimary : Color apply on application Title.
  • windowBackground : Color apply on layout of an application.
  • navigationBarColor : Color apply on navigationBar.

Elevation

Views can cast shadows, and the elevation value of a view determines the size of its shadow and its drawing order.

To set the elevation of a view, use the android:elevation attribute in your layouts.

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

Create new android application project.Go to activity_main.xml and add TextView,Button.Also Apply  Elevation on TextView.

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

So let’s customize your theme.Go to values > styles and following items in your current theme style tag.Don’t Touch anything else :).

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

So,you are done with simple Material Design.Next you animate or apply transition on your activity/class.

For that purpose create simple layout and its concerning class.Don’t forget to declare new activity in Android Manifest.xml file.

next.xml

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

Next.java

package developer.codecmaterialdesign;

import android.app.Activity;
import android.os.Bundle;

public class Next extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.next);
	}

}

Now go to MainActivity.java.Refer id of Button and apply click event.Create method to animate your activity using makeSceneTranistionAnimation of ActionOptions class.
MainActivity.java

package developer.codecmaterialdesign;

import android.support.v7.app.ActionBarActivity;
import android.transition.Explode;
import android.app.Activity;
import android.app.ActivityOptions;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;


public class MainActivity extends Activity {

	Button btn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
     // enable transitions
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        setContentView(R.layout.activity_main);
        btn = (Button) findViewById(R.id.button1);
        btn.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				action();
			}
		});
    }
    //material design custom animation
    public void action(){
    	getWindow().setExitTransition(new Explode());
        Intent intent = new Intent(this, Next.class);
        startActivity(intent,
                      ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
    }
    
}

Android Manifest.xml

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

Run your android application project.

material design custom animation,material design,material design in android,material design android, how to customize theme using material design, how to customize theme using material design android, how to customize theme using material design in android tutorial, material design android tutorial,how to change color of notification bar, how to change color of natification bar in android, elevation,elevation in android,custom animation,how to animate an activity, how to animate an activity on button click in android tutorial, colorPrimaryDark,colorPrimary,textColorPrimary,windowBackground, navigationBarColor,material design custom animation android,

You can download code to check how it animates the activity.

That’s it for this tutorial.

Thanks