TypedArray.GetDimensionPixelSize(Int32, Int32) Method

Definition

Retrieve a dimensional unit attribute at <var>index</var> for use as a size in raw pixels.

[Android.Runtime.Register("getDimensionPixelSize", "(II)I", "GetGetDimensionPixelSize_IIHandler")]
public virtual int GetDimensionPixelSize (int index, int defValue);
[<Android.Runtime.Register("getDimensionPixelSize", "(II)I", "GetGetDimensionPixelSize_IIHandler")>]
abstract member GetDimensionPixelSize : int * int -> int
override this.GetDimensionPixelSize : int * int -> int

Parameters

index
Int32

Index of attribute to retrieve.

defValue
Int32

Value to return if the attribute is not defined or not a resource.

Returns

Attribute dimension value multiplied by the appropriate metric and truncated to integer pixels, or defValue if not defined.

Attributes

Exceptions

if the TypedArray has already been recycled.

if the attribute is defined but is not a dimension.

Remarks

Retrieve a dimensional unit attribute at <var>index</var> for use as a size in raw pixels. This is the same as #getDimension, except the returned value is converted to integer pixels for use as a size. A size conversion involves rounding the base value, and ensuring that a non-zero base value is at least one pixel in size.

This method will throw an exception if the attribute is defined but is not a dimension.

Java documentation for android.content.res.TypedArray.getDimensionPixelSize(int, int).

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

See also

  • <xref:Android.Content.Res.TypedArray.GetDimension(System.Int32%2c+System.Single)>
  • <xref:Android.Content.Res.TypedArray.GetDimensionPixelOffset(System.Int32%2c+System.Int32)>