我正在使用 Xamarin.Forms 開發一個應用程式,并且我正在嘗試將啟影片面插入到我的 Android 專案中。
我找到了一些使用背景顏色和靜態 png 影像創建啟影片面的教程,但我想使用我的 svg 影片作為啟影片面。我以為我可以按照靜態影像的教程,只需用 svg 影片替換 png 影像,但它沒有用。這是我到目前為止所擁有的:
開SplashActivity.cs:
[Activity(Label = "SplashActivity", Theme = "@style/Theme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
}
protected override void OnResume()
{
base.OnResume();
Task startupWork = new Task(() => { SimulateStartup(); });
startupWork.Start();
}
async void SimulateStartup()
{
await Task.Delay(5000);
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
}
開MainActivity.cs:
// I only changed the MainLauncher property to false
[Activity(Label = "MyApp", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize )]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
}
在styles.xml(在 Xamarin.Android 專案中):
<style name="Theme.Splash" parent="android:Theme">
<item name="android:windowBackground">@drawable/desenhando5s</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="colorPrimaryDark">#004632</item>
</style>
當我運行應用程式時,它只顯示一個黑屏作為啟動螢屏,然后像往常一樣顯示我的登錄頁面。誰能告訴我我必須做什么才能將我的影片設定為啟影片面?
(僅供參考:如果有人想知道,我使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/454220.html
