Xamarin(Android)制作启动画面

匿名 (未验证) 提交于 2019-12-02 22:06:11

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();         }     }

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!