从零开始学Xamarin.Forms(三) Android 制作启动画面
时间:2014-08-11 17:47:32
收藏:0
阅读:431
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();
}
}
从零开始学Xamarin.Forms(三) Android 制作启动画面,布布扣,bubuko.com
原文:http://blog.csdn.net/zapzqc/article/details/38496117
评论(0)