码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2017-12-15 22:41:50      阅读:271      评论:0      收藏:0      [点我收藏+]

标签:ati   sources   启动   cte   owb   void   not   prot   center   

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

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

   

2.在其中的 Drawable 文件夹下创建 splashscreen.xml ,内容为:
  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,设置其创建内容如下:
  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”!

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

标签:ati   sources   启动   cte   owb   void   not   prot   center   

原文地址:http://www.cnblogs.com/LuoEast/p/8044964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!