加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

xaml – Windows UWP扩展的初始屏幕图像在移动设备上呈现错误

发布时间:2020-12-14 02:51:25 所属栏目:Windows 来源:网络整理
导读:我为我的 windows uwp应用程序构建了一个扩展的启动画面.我从这个页面跟随示例代码,包括xaml for extended spash screen Display a splash screen for more time 它在桌面窗口上正确呈现,它完全居中并与初始的闪屏图像完全对齐,但是当我尝试移动模拟器时,(我
我为我的 windows uwp应用程序构建了一个扩展的启动画面.我从这个页面跟随示例代码,包括xaml for extended spash screen

Display a splash screen for more time

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

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

enter image description here

我对扩展启动页面的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>

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

enter image description here

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

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

enter image description here

编辑:我的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));

}

解决方法

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

void PositionImage()
{
    extendedSplashImage.SetValue(Canvas.LeftProperty,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.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;
    }
}

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读