移动设备上的Windows UWP扩展启动画面图像渲染不正确

ero*_*las 5 xaml win-universal-app

我为我的windows uwp应用程序构建了一个扩展的启动画面.我从这个页面跟随示例代码,包括xaml for extended spash screen

显示启动画面更长时间

它在桌面窗口上正确呈现,它完全居中并与初始的闪屏图像完全对齐,但是当我尝试移动模拟器时,(我在720p尝试了5英寸屏幕之一),扩展的闪屏页面图像看起来太大了(它看起来几乎要大两倍或三倍),并且看起来被切断到页面的右下角,我假设进度环在图像下方并超出页面边界,因此它不可见.

这是它在移动设备上的样子,左边的图像是初始的初始屏幕,右边的那个是扩展的初始页面.

在此输入图像描述

我对扩展启动页面的XAML是这样的

<Page
    x:Class="MyApp_Win10.ExtendedSplash"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp_Win10"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="#FF000012" >
        <Canvas>
        <Image x:Name="extendedSplashImage" Source="Assets/SplashScreen/SplashScreenImage3.png"/>
        <ProgressRing Name="splashProgressRing"   IsActive="True" Width="60" Height="60"  HorizontalAlignment="Center"></ProgressRing>
        </Canvas>
    </Grid>
</Page>
Run Code Online (Sandbox Code Playgroud)

我的package.appmanifest看起来像这样.(Assets forlder中有一个图像创建为SplashScreenImage3.scale-200.png,尺寸为1240 wx 600 h)

在此输入图像描述

编辑: 我将剩余的3个图像比例150,125和100添加到package.appmanifest但它没有任何区别.由于扩展的启动页面与初始启动页面不同,我认为它选择了我在XAML中编写的确切图像文件 - 这是尺寸为1240 wx 600 h的完整尺寸.

此外,在扩展启动的代码隐藏中,这些是启动画面的坐标

在此输入图像描述

编辑:我的PositionImage()和PositionRing()函数

void PositionImage()
{
    extendedSplashImage.SetValue(Canvas.LeftProperty, splashImageRect.X);
    extendedSplashImage.SetValue(Canvas.TopProperty, splashImageRect.Y);

    extendedSplashImage.Height = splashImageRect.Height;
    extendedSplashImage.Width = splashImageRect.Width;

}

void PositionRing()
{
    splashProgressRing.SetValue(Canvas.LeftProperty, splashImageRect.X + (splashImageRect.Width * 0.5) - (splashProgressRing.Width * 0.5));
    splashProgressRing.SetValue(Canvas.TopProperty, (splashImageRect.Y + splashImageRect.Height + splashImageRect.Height * 0.1));

}
Run Code Online (Sandbox Code Playgroud)

sjs*_*sjs 2

确保在 PositionImage() 和 PositionRing() 函数中,当设备是手机时,您可以按如下方式处理这种情况

void PositionImage()
{
    extendedSplashImage.SetValue(Canvas.LeftProperty, splashImageRect.X);
    extendedSplashImage.SetValue(Canvas.TopProperty, splashImageRect.Y);

    if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
    {
        extendedSplashImage.Height = splashImageRect.Height / ScaleFactor;
        extendedSplashImage.Width = splashImageRect.Width / ScaleFactor;
    }
    else
    {
        extendedSplashImage.Height = splashImageRect.Height;
        extendedSplashImage.Width = splashImageRect.Width;
    }
}

void PositionRing()
{
    splashProgressRing.SetValue(Canvas.LeftProperty, splashImageRect.X + (splashImageRect.Width * 0.5) - (splashProgressRing.Width * 0.5));
    splashProgressRing.SetValue(Canvas.TopProperty, (splashImageRect.Y + splashImageRect.Height + splashImageRect.Height * 0.1));

    if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
    {
        splashProgressRing.Height = splashProgressRing.Height / ScaleFactor;
        splashProgressRing.Width = splashProgressRing.Width / ScaleFactor;
    }
}
Run Code Online (Sandbox Code Playgroud)

//Variable to hold the device scale factor (use to determine phone screen resolution)
private double ScaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; 
Run Code Online (Sandbox Code Playgroud)