Download Code

Xamarin Material Design Example 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 this xamarin material design example 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,Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example Android

Create new xamarin material design example android application project.Go to Main.axml and add TextView,Button.Also Apply  Elevation on TextView.

Main.axml

Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example Android

So let’s customize your theme.Go to values directory,create new styles.xml file and add following xml code.

Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example Android

Now go to your Android Manifest.xml file under Properties directory.Add Theme within application tag.

Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example 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.

next.axml

Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example Android

Next.cs

namespace XamarinMaterialDesign
{
	[Activity(Label = "Next")]
	public class Next : Activity
	{
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);
			SetContentView(Resource.Layout.next);
			// Create your application here
		}
	}
}

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

MainActivity.cs

namespace XamarinMaterialDesign
{
	[Activity(Label = "XamarinMaterialDesign", MainLauncher = true, Icon = "@mipmap/icon")]
	public class MainActivity : Activity
	{
		Button btn;

		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			// Set our view from the "main" layout resource
			SetContentView(Resource.Layout.Main);
			btn = (Button)FindViewById(Resource.Id.button1);
			btn.Click += Btn_Click;

		}

		void Btn_Click(object sender, System.EventArgs e)
		{
			StartActivity(new Intent(Application.Context, typeof(Next)), ActivityOptions.MakeSceneTransitionAnimation(this).ToBundle());
		}
	}
}

Deploy xamarin material design example android application project.

Xamarin Material Design, Xamarin Material Design Example, Xamarin Material Design Example android, Material Design Example Android

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

That’s it for xamarin material design example android tutorial.

For Java example visit AndroidCodec.

Thanks.