Windows Phone 8 適應多屏解析度

來源:互聯網
上載者:User

標籤:設定   sys   load   soft   term   private   樣式   app   dia   

Windows Phone 8 比較 windows phone 7 來說有很多功能及效能上的提升例如支援多核 CUP、支援SD卡、多種解析度、 顯然WP7 WVGA - 480x800 的已經不能完全滿足所使用者的需求,很多使用者喜歡大螢幕高分辨的手機,隨著大屏手機的逐漸推出 WP8 也是支援大解析度的螢幕【WXGA - 768x1280 和 720P - 720x1280】

之前跟大家提起過關於應用設配WP8多種解析度的事情,但是可能還是有些同學不是很明白如何判斷當前手機的解析度以及如何讓應用自適應當前的手機解析度 今天我給大家詳細的介紹一下。

Windows phone 8 支援的螢幕解析度有三種如下:

其中我們可以清楚的看到 WVGA 和 WXGA的螢幕橫寬比例都是 15:9 的,只有在720P 的情況下是 16:9 的這點要提醒大家有些應用或許就要對720P的情況進行特殊處理下 例如一些圖片或者視頻類的應用。

另外相信很多同學想實現全屏或者更改系統時間電量表徵圖顏色 請使用 SystemTray 進行設定:

 

void MainPage_Loaded(object sender, RoutedEventArgs e)        {            ProgressIndicator progress = new ProgressIndicator            {                IsVisible = true,                IsIndeterminate = true,                Text = "Downloading details..."            };            SystemTray.SetProgressIndicator(this, progress);            SystemTray.BackgroundColor = System.Windows.Media.Colors.Red;            SystemTray.ForegroundColor = System.Windows.Media.Colors.Blue;            //SystemTray.IsVisible = false;        }

 

通過上面的方法就可以隱藏狀態條 或 根據應用的樣式來調整 Tray的樣式,個人感覺比較實用在這裡給大家介紹一下。

當然今天的重點還是多解析度的支援 以下是實現一個 ResolutionHeper class 判斷當前螢幕解析度的方法:

public enum Resolutions { WVGA, WXGA, HD720p };public static class ResolutionHelper{   private static bool IsWvga   {      get      {         return App.Current.Host.Content.ScaleFactor == 100;      }   }   private static bool IsWxga   {      get       {          return App.Current.Host.Content.ScaleFactor == 160;       }   }        private static bool Is720p   {      get       {          return App.Current.Host.Content.ScaleFactor == 150;       }   }   public static Resolutions CurrentResolution   {      get      {         if (IsWvga) return Resolutions.WVGA;         else if (IsWxga) return Resolutions.WXGA;         else if (Is720p) return Resolutions.HD720p;         else throw new InvalidOperationException("Unknown resolution");      }   }}

 

上面這段代碼是使用 System.Windows.Interop 中的

public int ScaleFactor { get; }

 

 The scale factor for the current application content area.

通過螢幕比例來判斷螢幕解析度。 

另外在不同解析度的手機上需要使用相應的SplashScreenImage.jpg檔案來完美適應螢幕的大小,否則系統將會自動縮放。

Windows Phone 8 適應多屏解析度

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.