Share via


LayerDrawable.SetLayerGravity(Int32, GravityFlags) Method

Definition

Sets the gravity used to position or stretch the specified layer within its container.

[Android.Runtime.Register("setLayerGravity", "(II)V", "GetSetLayerGravity_IIHandler", ApiSince=23)]
public virtual void SetLayerGravity (int index, Android.Views.GravityFlags gravity);
[<Android.Runtime.Register("setLayerGravity", "(II)V", "GetSetLayerGravity_IIHandler", ApiSince=23)>]
abstract member SetLayerGravity : int * Android.Views.GravityFlags -> unit
override this.SetLayerGravity : int * Android.Views.GravityFlags -> unit

Parameters

index
Int32

the index of the drawable to adjust

gravity
GravityFlags

the gravity to set for the layer

Attributes

Remarks

Sets the gravity used to position or stretch the specified layer within its container. Gravity is applied after any layer insets (see #setLayerInset(int, int, int, int, int)) or padding (see #setPaddingMode(int)).

If gravity is specified as Gravity#NO_GRAVITY, the default behavior depends on whether an explicit width or height has been set (see #setLayerSize(int, int, int)), If a dimension is not set, gravity in that direction defaults to Gravity#FILL_HORIZONTAL or Gravity#FILL_VERTICAL; otherwise, gravity in that direction defaults to Gravity#LEFT or Gravity#TOP.

Java documentation for android.graphics.drawable.LayerDrawable.setLayerGravity(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