Let’s start

Step 1: Open Visual Studio->New Project->Templates->Visual C#->Android->Blank App
Select Blank App. Then give Project Name and Project Location.
Step 2: Next go to Solution Explorer-> Project Name->Resources->drawable then Right Click to Add->New Item then open new Dialog box.

Step 3: That Dialog box to Select XML File and give Name for Animation.xml.
Step 4: Next open Solution Explorer-> Project Name->Resources->drawable->Animation.xml click to open Design View. Then give following code.

XML Code:
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <item android:drawable="@drawable/img1" android:duration="100" />
  4. <item android:drawable="@drawable/img2" android:duration="100" />
  5. <item android:drawable="@drawable/img3" android:duration="100" />
  6. </animation-list>
Step 5: Next open Solution Explorer-> Project Name->Resources->layout->Main.axml click to open Design View

Step 6: Select Toolbar Drag and Drop ImageView Design.
AXML Code:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:orientation="vertical"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:minWidth="25px"
  7. android:minHeight="25px">
  8. <ImageView
  9. android:src="@android:drawable/ic_menu_gallery"
  10. android:layout_width="match_parent"
  11. android:layout_height="wrap_content"
  12. android:id="@+id/imageView1" />
  13. </LinearLayout>
Step 7: Next open MainActivity.cs page, then Add Namespace and following code.

Namespace: using Android.Graphics.Drawables;

C# Code:
  1. using System;
  2. using Android.App;
  3. using Android.Content;
  4. using Android.Runtime;
  5. using Android.Views;
  6. using Android.Widget;
  7. using Android.OS;
  8. using Android.Graphics.Drawables;
  9. namespace Animation
  10. {
  11. [Activity(Label = "Animation", MainLauncher = true, Icon = "@drawable/icon")]
  12. public class MainActivity : Activity
  13. {
  14. private AnimationDrawable Animation;
  15. protected override void OnCreate(Bundle bundle)
  16. {
  17. base.OnCreate(bundle);
  18. // Set our view from the "main" layout resource
  19. SetContentView(Resource.Layout.Main);
  20. // Load the animation from resources
  21. Animation = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.animation);
  22. ImageView imageView = FindViewById<ImageView>(Resource.Id.imageView1);
  23. imageView.SetImageDrawable(Animation);
  24. }
  25. }
  26. }
Step 8: Then Debug and run the app Working Animation Rotate in Image.

Finally, we have successfully created Xamarin Android AnimationDrawble Application.