DisplayMetrics

来源:互联网 发布:python 字符串 编辑:程序博客网 时间:2024/04/30 10:01

java.lang.Object

-android.util.DisplayMetrics

Class Overview

A structure describing general information about a display, such as its size, density, and font scaling.

To access the DisplayMetrics members, initialize an object like this:

DisplayMetrics metrics = new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(metrics);

public static final intDENSITY_DEFAULT

Since: API Level 4

The reference density used throughout the system.

Constant Value:160 (0x000000a0)

public static final intDENSITY_HIGH

Since: API Level 4

Standard quantized DPI for high-density screens.

Constant Value:240 (0x000000f0)

public static final intDENSITY_LOW

Since: API Level 4

Standard quantized DPI for low-density screens.

Constant Value:120 (0x00000078)

public static final intDENSITY_MEDIUM

Since: API Level 4

Standard quantized DPI for medium-density screens.

Constant Value:160 (0x000000a0)

public static final intDENSITY_XHIGH

Since: API Level 9

Standard quantized DPI for extra-high-density screens.

Constant Value:320 (0x00000140)

public floatdensity

The logical density of the display. This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.

This value does not exactly follow the real screen size (as given by xdpi and ydpi,but rather is used to scale the size of the overall UI in steps based on gross changes in the display dpi. For example, a 240x320 screen will have a density of 1 even if its width is 1.8", 1.3", etc. However, if the screen resolution is increased to 320x480 but the screen size remained 1.5"x2" then the density would be increased (probably to 1.5).

public intdensityDpi

The screen density expressed as dots-per-inch. May be either DENSITY_LOW,DENSITY_MEDIUM, or DENSITY_HIGH.

public intheightPixels

The absolute height of the display in pixels.

public floatscaledDensity

Since: API Level 1

A scaling factor for fonts displayed on the display. This is the same as density, except that it may be adjusted in smaller increments at runtime based on a user preference for the font size.

public intwidthPixels

Since: API Level 1

The absolute width of the display in pixels.

public floatxdpi

Since: API Level 1

The exact physical pixels per inch of the screen in the X dimension.

public floatydpi

Since: API Level 1

The exact physical pixels per inch of the screen in the Y dimension.


Defy测试结果:

density=1.5,width=480,height=854,scaledDensity=1.5,xdpi=144.0,ydpi=144.0

原创粉丝点击