Xamarin(Android)制作启动画面

1、将启动图片保存到Drawable文件夹下

2、在Drawable文件夹下创建splashscreen.xml

<?xml version="1.0" encoding="utf-8" ?> 
<bitmap xmlns:android="http://schemas.android.com/apk/res/android" 
android:src="@drawable/splash_screen" 
android:gravity="fill" 
android:layout_gravity="center"/>

3、在android项目的 Resources 文件夹下添加“Values”文件夹,创建 Styles.xml,设置其创建内容如下:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="Theme.Splash"
    parent="android:Theme.Holo.Light">
    <item name="android:windowBackground">@drawable/splashscreen</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsTranslucent">false</item>
    <item name="android:windowIsFloating">false</item>
    <item name="android:backgroundDimEnabled">true</item>
  </style>
</resources>

4、在Android项目下创建一个SplashScreen.cs类

 [Activity(MainLauncher = true, NoHistory = true, Theme = "@style/Theme.Splash",
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class SplashScreen : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            var intent = new Intent(this, typeof(MainActivity));
            StartActivity(intent);
            Finish();
        }
    }

 

posted @ 2019-07-20 12:37  SoFarAway  阅读(873)  评论(0编辑  收藏  举报