Freigeben über


Resources.DisplayMetrics Property

Definition

Returns the current display metrics that are in effect for this resource object.

public virtual Android.Util.DisplayMetrics? DisplayMetrics { [Android.Runtime.Register("getDisplayMetrics", "()Landroid/util/DisplayMetrics;", "GetGetDisplayMetricsHandler")] get; }
[<get: Android.Runtime.Register("getDisplayMetrics", "()Landroid/util/DisplayMetrics;", "GetGetDisplayMetricsHandler")>]
member this.DisplayMetrics : Android.Util.DisplayMetrics

Property Value

The resource's current display metrics.

Attributes

Remarks

Returns the current display metrics that are in effect for this resource object. The returned object should be treated as read-only.

Note that the reported value may be different than the window this application is interested in.

The best practices is to obtain metrics from WindowManager#getCurrentWindowMetrics() for window bounds. The value obtained from this API may be wrong if Context#getResources() is from non-android.annotation.UiContext. For example, use the DisplayMetrics obtained from Application#getResources() to build android.app.Activity UI elements especially when the android.app.Activity is in the multi-window mode or on the secondary Display. <p/>

Java documentation for android.content.res.Resources.getDisplayMetrics().

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.

Applies to