我想知道什么是在Windows Phone 7中开发应用程序时处理不同屏幕分辨率的最佳方法。
因为我在480 x 800像素中取代所有应用程序,而且我知道并非全部移动支持480 x 800像素分辨率。
如果我在XAML中进行了宽度,高度,边距等的编码,那么当手机不支持480x800分辨率时,它将引起问题。
那么,在单个应用程序中管理所有分解蛋白的最佳方法是什么?像在Android中一样具有不同的文件夹来分辨分辨率(HDPI,LDPI)。
帮助我
请阅读我先前关于该主题的答案:WP8多分辨率支持,WP8 mutli-lastolution的API,DevCenter多重XAP支持,以及WP7&WP8共同开发指南。
专门查看WP7&WP8在运行时改编下的共同开发指南。具有此代码段:
public Uri GetScaledImageUri(String imageName)
{
int scaleFactor = (int)Application.Current.Host.Content.ScaleFactor;
switch (scaleFactor)
{
case 100: return new Uri(imageName + "_wvga.png", UriKind.RelativeOrAbsolute);
case 150: return new Uri(imageName + "_720p.png", UriKind.RelativeOrAbsolute);
case 160: return new Uri(imageName + "_wxga.png", UriKind.RelativeOrAbsolute);
default: throw new InvalidOperationException("Unknown resolution type");
}
}
// Next line will load a correct image depending on the resolution of the device
MyImage.Source = new BitmapImage(GetScaledImageUri("myImage"));
还可以查看具有这三个相互排斥的代码段的WP8 Mutli分辨率的API:
Image myImage = new Image();
if (MultiRes.Is720p)
myImage.Source = new BitmapImage(new Uri("puppies.720p.jpg"));
else if (MultiRes.IsWvga)
myImage.Source = new BitmapImage(new Uri("puppies.wvga.jpg"));
else if (MultiRes.IsWxga)
myImage.Source = new BitmapImage(new Uri("puppies.wxga.jpg"));
if (MultiRes.Is720p)
myImage.Source = new BitmapImage(new Uri(@"assets16by9AspectRatiopuppies.jpg"));
else
myImage.Source = new BitmapImage(new Uri(@"assets15by9AspectRatiopuppies.jpg"));
if (MultiRes.IsHighResolution)
myImage.Source = new BitmapImage(new Uri(@"assetsHDpuppies.jpg"));
else
myImage.Source = new BitmapImage(new Uri(@"assetsSDpuppies.jpg"));
我在开发WP8中开发应用程序时有解决方案分辨率的解决方案。
justinangel anser也是正确的,但有些是对的,因为它包含了许多需要维护的代码,并且有些困难。
因此,使用Telerik Redcontrols.NO代码为维护是必要的,并且根据分辨率的不同,可以简单地加载不同图像的简单方法。
请reffer此链接
Windows Phone 8中的多分辨率支持使
变得轻松希望这对所有WP8开发人员都是有帮助的。