Xamarin Android and xamarinandroid
...... (Empty talk)
There are very few technical materials developed by Xamarin. After learning, we will share our learning process and problems with you.
Splash Screen is an image that appears when an application is started. Generally, the App's Splash Screen contains dynamic advertisement information.
First, learn how to load a fixed Splash Screen.
1. Add code in Resource/values/Styles. xml.
<?xml version="1.0" encoding="UTF-8" ?><resources> <style name="Theme.SplashActivity" parent="android:Theme.Holo.Light.NoActionBar"> <item name="android:windowBackground">@drawable/ic_splash_logo</item> </style></resources>
Android: windowBackground is set to the image to be loaded.
2. Create a class file of SplashActivity. The Code is as follows:
Namespace MyApplication {using System. threading; using Android. app; using Android. OS; [Activity (Label = "SplashScreen", MainLauncher = true, NoHistory = true, Theme = "@ style/Theme. splashActivity ")] public class SplashActivity: Activity {protected override void OnCreate (Bundle bundle) {base. onCreate (bundle); // sets the Thread to wait for Thread. sleep (2000); // start MainActivity StartActivity (typeof (MainActivity ));}}}
Parameter description:
1. MainLauncher: indicates that the Activity is a startup Activity. When the application starts, it is automatically started from this page.
2. Theme-custom Style File.
3. NoHistory-by default, you can switch from an Activity to the next Activity, or back from the next Activity to the previous one. This is because,
Here is the Splash Screen, which does not need to be returned to the previous one. Therefore, it does not record historical operations.
Note: you cannot set the MainLauncher attribute in MainActivity. If this attribute is set, two application packages will appear during installation.