{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ContentScale.Companion

public static class ContentScale.Companion


Companion object containing commonly used ContentScale implementations

Summary

Public methods

static final @NonNull ContentScale

Scale the source uniformly (maintaining the source's aspect ratio) so that both dimensions (width and height) of the source will be equal to or larger than the corresponding dimension of the destination.

static final @NonNull ContentScale

Scale horizontal and vertically non-uniformly to fill the destination bounds.

static final @NonNull ContentScale

Scale the source maintaining the aspect ratio so that the bounds match the destination height.

static final @NonNull ContentScale

Scale the source maintaining the aspect ratio so that the bounds match the destination width.

static final @NonNull ContentScale

Scale the source uniformly (maintaining the source's aspect ratio) so that both dimensions (width and height) of the source will be equal to or less than the corresponding dimension of the destination

static final @NonNull ContentScale

Scale the source to maintain the aspect ratio to be inside the destination bounds if the source is larger than the destination.

static final @NonNull FixedScale

Do not apply any scaling to the source

Public methods

getCrop

public static final @NonNull ContentScale getCrop()

Scale the source uniformly (maintaining the source's aspect ratio) so that both dimensions (width and height) of the source will be equal to or larger than the corresponding dimension of the destination.

This ContentScale implementation in combination with usage of Alignment.Center provides similar behavior to android.widget.ImageView.ScaleType.CENTER_CROP

getFillBounds

public static final @NonNull ContentScale getFillBounds()

Scale horizontal and vertically non-uniformly to fill the destination bounds.

getFillHeight

public static final @NonNull ContentScale getFillHeight()

Scale the source maintaining the aspect ratio so that the bounds match the destination height. This can cover a larger area than the destination if the height is larger than the width.

getFillWidth

public static final @NonNull ContentScale getFillWidth()

Scale the source maintaining the aspect ratio so that the bounds match the destination width. This can cover a larger area than the destination if the width is larger than the height.

getFit

public static final @NonNull ContentScale getFit()

Scale the source uniformly (maintaining the source's aspect ratio) so that both dimensions (width and height) of the source will be equal to or less than the corresponding dimension of the destination

This ContentScale implementation in combination with usage of Alignment.Center provides similar behavior to android.widget.ImageView.ScaleType.FIT_CENTER

getInside

public static final @NonNull ContentScale getInside()

Scale the source to maintain the aspect ratio to be inside the destination bounds if the source is larger than the destination. If the source is smaller than or equal to the destination in both dimensions, this behaves similarly to None. This will always be contained within the bounds of the destination.

This ContentScale implementation in combination with usage of Alignment.Center provides similar behavior to android.widget.ImageView.ScaleType.CENTER_INSIDE

getNone

public static final @NonNull FixedScale getNone()

Do not apply any scaling to the source