Xamarin(Android)制作啟動畫面


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM