Android Specific Animations Xamarin.forms - Splash Screen
I have made a splash screen for Android by implementing a new Activity. It points to a xml theme that includes android specific code (@style/Splash). That points to a drawable xml
Solution 1:
1. Create a Anim
folder and put the hyperspace_jump.xml
file in it.
2. Create the layouts.
SplashScreen Layout:
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"p1:minWidth="25px"p1:minHeight="25px"p1:layout_width="match_parent"p1:layout_height="match_parent"p1:background="@android:color/white"p1:id="@+id/relativeLayout1">
<ImageView
p1:layout_width="wrap_content"
p1:layout_height="wrap_content"
p1:id="@+id/imageView"
p1:layout_centerVertical="true"
p1:layout_centerHorizontal="true"
p1:src="@drawable/a01" />
</RelativeLayout>
Main Layout:
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:minWidth="25px"android:minHeight="25px"><TextViewandroid:text="Main Activity Started"android:textAppearance="?android:attr/textAppearanceLarge"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/textView1"/></LinearLayout>
3. Code Behind:
SplashScreenActivity:
publicclassSplashScreenActivity : Activity
{
ImageView imageView;
Animation view_animation;
TextView textview;
protectedoverridevoidOnCreate(Bundle bundle)
{
base.OnCreate(bundle);
RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);
SetContentView (Resource.Layout.SplashScreen);
imageView = (ImageView)FindViewById(Resource.Id.imageView);
view_animation = AnimationUtils.LoadAnimation(this,Resource.Animation.hyperspace_jump);
imageView.StartAnimation(view_animation);
view_animation.AnimationEnd += Rotate_AnimationEnd;
}
privatevoidRotate_AnimationEnd(object sender, Animation.AnimationEndEventArgs e)
{
Finish();
StartActivity(typeof(MainActivity));
}
}
MainActivity:
protectedoverridevoidOnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
Toast.MakeText(this, "Welcome to MainActivity", ToastLength.Long).Show();
}
4. Screenshot:
You could download from the GitHub for reference. https://github.com/WendyZang/Test/tree/master/SplashScreenDemo
Post a Comment for "Android Specific Animations Xamarin.forms - Splash Screen"