Xamarin.Forms (Android制作启动画面)

http://blog.csdn.net/zapzqc/article/details/38496117

    Xamarin.Forms 在启动的时候相当慢,必须添加一个启动界面,步骤如下:
1.将启动画面的图片命名为:splash_screen.png,并拷贝到 Resources 文件夹下的相应 Drawable 文件夹中;

   

2.在其中的 Drawable 文件夹下创建 splashscreen.xml ,内容为:
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8" ?>   
  2. <bitmap xmlns:android="http://schemas.android.com/apk/res/android"   
  3. android:src="@drawable/splash_screen"   
  4. android:gravity="fill"   
  5. android:layout_gravity="center"/>  
 
3.在android项目的 Resources 文件夹下添加“Values”文件夹,创建 Styles.xml,设置其 创建内容如下:
[html] view plain copy
  1. <?xml version="1.0" encoding="utf-8" ?>  
  2. <resources>  
  3.   <style name="Theme.Splash"  
  4.     parent="android:Theme.Holo.Light">  
  5.     <item name="android:windowBackground">@drawable/splashscreen</item>  
  6.     <item name="android:windowNoTitle">true</item>  
  7.     <item name="android:windowIsTranslucent">false</item>  
  8.     <item name="android:windowIsFloating">false</item>  
  9.     <item name="android:backgroundDimEnabled">true</item>  
  10.   </style>  
  11. </resources>  

4.在Android项目下创建一个SplashScreen.cs类,内容如下:
[csharp] view plain copy
  1. [Activity(MainLauncher = true, NoHistory = true, Theme = "@style/Theme.Splash",  
  2.    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]  
  3.    public class SplashScreen : Activity  
  4.    {  
  5.        protected override void OnCreate(Bundle bundle)  
  6.        {  
  7.            base.OnCreate(bundle);  
  8.            var intent = new Intent(this, typeof(MainActivity));  
  9.            StartActivity(intent);  
  10.            Finish();  
  11.        }  
  12.    }  
 
5.去掉MainActivity.cs类中的“MainLauncher = true”。

注意,两个xml文件(包括图片文件)属性中的生成操作必须为“AndroidResource”!

转载于:https://www.cnblogs.com/LuoEast/p/8044964.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值