• Xamarin.Android 启动页


      打开软件的时候相当慢,会有白屏显示,这样的用户体验效果不好,所以需要增加一个启动页来过渡。步骤如下:

    第一步:根据自己需求找到一个png图片,用于启动展示,放在Drawable 文件夹下,我这里命名为Loading.png。

    第二步:在Drawable 文件夹下创建 splashscreen.xml,用于展示Loading.png。

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

    第三步:在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/loadingscreen</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>

    第四步:创建一个LoadingScreen.cs类,其作用是程序开启第一个调用的Activity

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    using Android.App;
    using Android.Content;
    using Android.OS;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.Content.PM;
    
    namespace App1
    {
        [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();
            }
        }
    }

    第五步:去掉MainActivity.cs类中的“MainLauncher = true”。

  • 相关阅读:
    C++11:限定作用域的枚举类型
    查询Windows用户SID
    终止git merging状态
    sed追加文件内容的几种方式
    显示一个目录下所有文件名字和对应的内容
    kvm常用指令
    路由相关指令和概念理解
    打开 macOS Sierra 允许“任何来源”选项,运行第三方应用
    Flutter Tips
    C++编写的Vector3类
  • 原文地址:https://www.cnblogs.com/swjian/p/9993806.html
Copyright © 2020-2023  润新知