简体   繁体   English

UWP自定义启动画面示例

[英]UWP Customized Splash Screen Sample

I want to create a splash screen in UWP. 我想在UWP中创建启动画面。 I want do more than just center an image in the screen. 我想做的不只是在屏幕上居中放置图像。 I thought it would be a lot more straight forward. 我认为这会更加直接。 I saw these articles: 我看到了这些文章:

https://docs.microsoft.com/en-us/previous-versions/windows/apps/hh868191(v=win.10) https://docs.microsoft.com/en-us/previous-versions/windows/apps/hh868191(v=win.10)

https://code.msdn.microsoft.com/windowsapps/Splash-Screen-in-Universal-42c0b57a https://code.msdn.microsoft.com/windowsapps/Splash-Screen-in-Universal-42c0b57a

When I first opened up this sample, I thought that it worked... But, it doesn't actually do anything. 当我第一次打开此样本时,我认为它可以工作...但是,它实际上没有任何作用。 It's actually just a furphy. 实际上这只是一种毛病。 If you look carefully at the screen, it actually just shows an image (defined in the manifest) for a second or two as the app is starting up, and then when the app is loaded, it switches to the extended screen with a progress ring. 如果您仔细查看屏幕,它实际上只是在启动应用程序时显示一两秒钟的图像(在清单中定义),然后在加载应用程序时,它会切换到带有进度环的扩展屏幕。 I've seen samples where people turn on the splash screen image, but that's not want I need to achieve. 我已经看到了人们打开启动屏幕图像的示例,但这并不是我所需要的。 Part of the problem is that UWP app startup time is terrible even on fast machines. 问题的一部分是,即使在快速的计算机上,UWP应用程序的启动时间也很糟糕。 Even blank apps with nothing in them take several seconds to start up. 即使没有任何内容的空白应用程序也要花费几秒钟来启动。

Is there a UWP sample floating around that actually a) cuts out the splash image from the manifest, and b) allows us to replace it with something else? 周围是否存在一个UWP样本,实际上是a)从清单中切出了启动画面,并且b)允许我们用其他东西替换它?

Note: I do not wish to remove the splash screen. 注意: 我不希望删除初始屏幕。 I want to customize it. 我要自定义它。

The main splash screen (centered splash screen image defined in the package.appxmanifest ) will always be displayed unless you make it optional - while even in this case it will be shown to the user when the app doesn't load immediately. 除非您将其设置为可选,否则将始终显示主启动屏幕(在package.appxmanifest定义的居中启动屏幕图像)-即使在这种情况下,当应用程序不立即加载时,也会显示给用户。

To make the splash screen optional, you have to open the manifest file as XML, add the following namespace declaration: 要使启动屏幕为可选,您必须以XML打开清单文件,添加以下名称空间声明:

<Package
  ...
  xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5">

And then add the uap5:optional attribute to your splash screen: 然后将uap5:optional属性添加到初始屏幕:

<uap:SplashScreen ... uap5:Optional="true" />

You can implement an extended splash screen, which is described in the articles you linked. 您可以实现扩展的初始屏幕,在链接的文章中对此进行了描述。 If you postpone all initialization for the extended splash screen, it is quite likely that the optional default splash screen will not display at all. 如果推迟扩展初始屏幕的所有初始化,则很有可能根本不会显示可选的默认初始屏幕。

However, although the samples only show the same image with progress ring, you can put any content you want on the extended splash screen, you are in full control of it because it is a normal Page . 但是,尽管样本仅显示带有进度环的同一图像,但是您可以将所需的任何内容放在扩展的初始屏幕上,但是由于它是普通的Page ,因此您可以完全控制它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM