1

Windows Phone 7 でアプリを開発しているときに、さまざまな画面解像度を処理する最善の方法を知りたいです。

私はすべてのアプリケーションを 480 x 800 ピクセルで開発しているため、すべてのモバイルが 480 x 800 ピクセルの解像度をサポートしているわけではありません。

xaml で幅、高さ、マージンなどをハードコードすると、電話が 480x800 の解像度をサポートしていない場合に問題が発生します。

では、単一のアプリケーションですべてのレゾルチンを管理する最良の方法は何ですか? Android のように、異なる解像度 (Hdpi、Ldpi) の異なるフォルダーがあります。

助けて

4

2 に答える 2

3

Zen of WP8 Multi-resolution supportAPIs for WP8 multi-resolutionDevCenter multiple XAP support、およびWP7 & WP8 co-development guideというトピックに関する以前の回答をお読みください。

具体的には、ランタイム適応の下にある 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"));

また、次の 3 つの相互に排他的なコード スニペットを持つWP8 マルチ解像度の 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(@"assets\16by9AspectRatio\puppies.jpg"));
else
    myImage.Source = new BitmapImage(new Uri(@"assets\15by9AspectRatio\puppies.jpg"));

if (MultiRes.IsHighResolution)
    myImage.Source = new BitmapImage(new Uri(@"assets\HD\puppies.jpg"));
else
    myImage.Source = new BitmapImage(new Uri(@"assets\SD\puppies.jpg"));
于 2012-12-26T05:10:36.037 に答える
0

wp8でアプリケーションを開発しているときに、異なる画面解像度を処理するための解決策を得ました。

JustinAngel anser も正しいですが、メンテナンスが必要なコードが多く含まれており、複雑なものもあります。

したがって、Telerik RedControls を使用してください。維持するためのコード ビハインドは必要なく、解像度に応じてさまざまな画像をロードする単純で簡単な方法です。

このリンクを参照してください

Windows Phone 8 でのマルチ解像度サポートが簡単に

これがすべての wp8 開発者の助けになることを願っています。

于 2012-12-28T05:15:44.500 に答える