原文: 从零开始学Xamarin.Forms(三) Android 制作启动画面

Xamarin.Forms 在启动的时候相当慢,必须添加一个启动界面,步骤如下: 1.将启动画面的图片命名为:splash_screen.png,并拷贝到 Resources 文件夹下的相应 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();        }    }

5.去掉MainActivity.cs类中的“MainLauncher = true”。

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



更多相关文章

  1. android FTP上传下载文件
  2. Android Studio添加so文件并打包到APK的lib文件夹中
  3. android studio打包 so文件
  4. android 6.0后usb otg设备不显示在文件管理器中
  5. 将Activity打包成jar文件
  6. Android学习笔记(六)-文件操作与SDCard读写访问

随机推荐

  1. Android属性动画Property Animation系列
  2. 文件编码的测试(android)
  3. 【Android】使用dex2jar 与JD-Gui 反编译
  4. android 查看解压后的.xml文件代码(axmlpr
  5. android 文本框输入法控制
  6. android service 学习(上)
  7. Android(安卓)系统数据库编程学习日志
  8. Android(安卓)自定义属性 attr format取
  9. android 编译模块
  10. cross compile toolchain for arm/androi