android單位詳解2(小翻譯)

來源:互聯網
上載者:User
文章目錄
  • 術語和概念

http://developer.android.com/guide/practices/screens_support.html

Terms and concepts
Screen size
Actual physical size, measured as the screen's diagonal.

For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra large.

Screen density
The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen.

For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.

Orientation
The orientation of the screen from the user's point of view. This is either landscape or portrait, meaning that the screen's aspect ratio is either wide or tall, respectively. Be aware that not only do different devices operate in different orientations by default, but the orientation can change at runtime when the user rotates the device.
Resolution
The total number of physical pixels on a screen. When adding support for multiple screens, applications do not work directly with resolution; applications should be concerned only with screen size and density, as specified by the generalized size and density groups.
Density-independent pixel (dp)
A virtual pixel unit that you should use when defining UI layout, to express layout dimensions or position in a density-independent way.

The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, which is the baseline density assumed by the system for a "medium" density screen. At runtime, the system transparently handles any scaling of the dp units, as necessary, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp equals 1.5 physical pixels. You should always use dp units when defining your application's UI, to ensure proper display of your UI on screens with different densities.

術語和概念

螢幕尺寸:

       實際的物理尺寸, 用螢幕的對角線測量.

       為了更加簡單, android 組織了所有的螢幕尺寸成四個一般化的尺寸: small, normal,large,extra large.

螢幕密度(dpi):

      螢幕的物理的地區的像素數量.通常和dpi相對應. 例如,low標準的螢幕密度在同樣螢幕下比normal和high標準下的像素數更少.

      也是為了更加簡單, andorid又組織了所有實際的螢幕密度成四個一般化的密度: low ,medium, high ,extra high.

方向 :

      螢幕的方向來自於使用者的觀察角度, 方向可以是橫向也可以是縱向, 相對應的就是螢幕的寬高的比例. 要知道不僅不同裝置的預設的操作方向不同, 而且當使用者旋轉螢幕的時候方向可以改變.

解析度:

      指一個螢幕的熱處理像素的總數. 當要對多種螢幕支援時,應用程式不直接與解析度打交道.應用程式應該考慮和螢幕的尺寸和密度打交道,因為它們被android系統一般化為一般的尺寸和密度組.

獨立於密度的像素(dp)

      指一個虛擬像素單元,你可以在你的UI單元裡使用它們表示布局的維度和位置以一種和密度無關的方式.

      一個獨立於密度的像素就是一個160dpi的螢幕的一個物理像素數.它是系統對於medium密度螢幕的假定的底線密度,在運行時,如果必要, 系統會根據使用者實際的螢幕密度透明的處理任何dp單元的縮放,dp到

      px的轉換是簡單的: px = dp*(dpi/160). 例如, 在一個240dpi的螢幕上, 1dp等於1.5px, 在你的應用程式UI你應該總是使用dp單元.來確保你的UI會適應不同的螢幕密度.

Range of screens supported

Starting with Android 1.6 (API Level 4), Android provides support for multiple screen sizes and densities, reflecting the many different screen configurations that a device may have. You can use features of the Android system to optimize your application's user interface for each screen configuration and ensure that your application not only renders properly, but provides the best user experience possible on each screen.

To simplify the way that you design your user interfaces for multiple screens, Android divides the range of actual screen sizes and densities into:

  • A set of four generalized sizes: small, normal, large, and xlarge

    Note: Beginning with Android 3.2 (API level 13), these size groups are deprecated in favor of a new technique for managing screen sizes based on the available screen width. If you're developing for Android 3.2 and greater, see Declaring Tablet Layouts for Android 3.2 for more information.

  • A set of four generalized densities: ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high)

The generalized sizes and densities are arranged around a baseline configuration that is a normal size and mdpi (medium) density. This baseline is based upon the screen configuration for the first Android-powered device, the T-Mobile G1, which has an HVGA screen (until Android 1.6, this was the only screen configuration that Android supported).

Each generalized size and density spans a range of actual screen sizes and densities. For example, two devices that both report a screen size of normal might have actual screen sizes and aspect ratios that are slightly different when measured by hand. Similarly, two devices that report a screen density of hdpi might have real pixel densities that are slightly different. Android makes these differences abstract to applications, so you can provide UI designed for the generalized sizes and densities and let the system handle any final adjustments as necessary. Figure 1 illustrates how different sizes and densities are roughly categorized into the different size and density groups.

Figure 1. Illustration of how Android roughly maps actual sizes and densities to generalized sizes and densities (figures are not exact).

螢幕支援的範圍

從安卓1.6開始, android提供對多種螢幕的尺寸和密度的支援.反映了裝置使用的許多不同螢幕的配置.你可以使用android系統的這些特性來對每一種螢幕配置都能最佳化你的應用程式介面,使你的應用程式不僅適當的渲染而且對每一種螢幕提供最好的使用者體驗.

為了簡化你適應多螢幕使用者介面的設計 , android劃分了一系列的螢幕尺寸和密碼,如下:

     四種泛化的尺寸: small, normal, large, and xlarge.

     注意: 從android3.2開始,這些尺寸都過時了,為了支援新的管理螢幕的技術. 如果你是android3.2或以上的開發人員, 看 Declaring Tablet Layouts for Android 3.2 這個連結得到更多的資訊..

     四種螢幕的密度: ldpi, mdpi,hdpi ,xhdpi.

這些泛化的尺寸和密度是根據正常尺寸和mdip密度而設計的. 這種設計的標準應用程式於第一款android手機, htc G1. 這個手機有一個HVGA(half VGA)螢幕,(一直到android1.6, 這都是android支援一唯一的螢幕配置). 每一種泛化的尺寸和密度跨越了一系列的實際的螢幕尺寸和密度. 例如, ...

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.