共用方式為


DisplayMetrics Class

Definition

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

[Android.Runtime.Register("android/util/DisplayMetrics", DoNotGenerateAcw=true)]
public class DisplayMetrics : Java.Lang.Object
[<Android.Runtime.Register("android/util/DisplayMetrics", DoNotGenerateAcw=true)>]
type DisplayMetrics = class
    inherit Object
Inheritance
DisplayMetrics
Attributes

Remarks

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

To access the DisplayMetrics members, retrieve display metrics like this:

context.getResources().getDisplayMetrics();

For UI layout, obtain android.view.WindowMetrics from WindowManager#getCurrentWindowMetrics(). DisplayMetrics should only be used for obtaining display related properties, such as #xdpi and #ydpi

See #density for more information about the differences between #xdpi, #ydpi and #density.

Java documentation for android.util.DisplayMetrics.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

DisplayMetrics()
DisplayMetrics(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Fields

Density140
Obsolete.

Intermediate density for screens that sit between #DENSITY_LOW (120dpi) and #DENSITY_MEDIUM (160dpi).

Density180
Obsolete.

Intermediate density for screens that sit between #DENSITY_MEDIUM (160dpi) and #DENSITY_HIGH (240dpi).

Density200
Obsolete.

Intermediate density for screens that sit between #DENSITY_MEDIUM (160dpi) and #DENSITY_HIGH (240dpi).

Density220
Obsolete.

Intermediate density for screens that sit between #DENSITY_MEDIUM (160dpi) and #DENSITY_HIGH (240dpi).

Density260
Obsolete.

Intermediate density for screens that sit between #DENSITY_HIGH (240dpi) and #DENSITY_XHIGH (320dpi).

Density280
Obsolete.

Intermediate density for screens that sit between #DENSITY_HIGH (240dpi) and #DENSITY_XHIGH (320dpi).

Density300
Obsolete.

Intermediate density for screens that sit between #DENSITY_HIGH (240dpi) and #DENSITY_XHIGH (320dpi).

Density340
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density360
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density400
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density420
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density440
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density450
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XHIGH (320 dpi) and #DENSITY_XXHIGH (480 dpi).

Density520
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XXHIGH (480 dpi) and #DENSITY_XXXHIGH (640 dpi).

Density560
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XXHIGH (480 dpi) and #DENSITY_XXXHIGH (640 dpi).

Density600
Obsolete.

Intermediate density for screens that sit somewhere between #DENSITY_XXHIGH (480 dpi) and #DENSITY_XXXHIGH (640 dpi).

DensityDefault
Obsolete.

The reference density used throughout the system.

DensityHigh
Obsolete.

Standard quantized DPI for high-density screens.

DensityLow
Obsolete.

Standard quantized DPI for low-density screens.

DensityMedium
Obsolete.

Standard quantized DPI for medium-density screens.

DensityTv
Obsolete.

This is a secondary density, added for some common screen configurations.

DensityXhigh
Obsolete.

Standard quantized DPI for extra-high-density screens.

DensityXxhigh
Obsolete.

Standard quantized DPI for extra-extra-high-density screens.

DensityXxxhigh
Obsolete.

Standard quantized DPI for extra-extra-extra-high-density screens.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Density

The logical density of the display.

DensityDeviceStable

The device's stable density.

DensityDpi

The screen density expressed as dots-per-inch.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
HeightPixels

The absolute height of the available display size in pixels.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ScaledDensity

A scaling factor for fonts displayed on the display.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

WidthPixels

The absolute width of the available display size in pixels.

Xdpi

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

Ydpi

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

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(DisplayMetrics)

Returns true if these display metrics equal the other display metrics.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetTo(DisplayMetrics)
SetToDefaults()
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to