Language

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

Name Description
DisplayMetrics()
DisplayMetrics(IntPtr, JniHandleOwnership)

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

Fields

Name Description
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).

Density390
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

Name Description
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

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
PeerReference

Gets the JNI object reference for this Java peer.

(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

Name Description
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(DisplayMetrics)

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

Equals(Object) (Inherited from JavaObject)
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)
SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
SetTo(DisplayMetrics)
SetToDefaults()
ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(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

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to