DrawableKt

public final class DrawableKt


Summary

Public methods

static final @NonNull Bitmap
DrawableKt.toBitmap(
    @NonNull Drawable receiver,
    @Px int width,
    @Px int height,
    @Nullable Bitmap.Config config
)

Return a Bitmap representation of this Drawable.

static final void
DrawableKt.updateBounds(
    @NonNull Drawable receiver,
    @Px int left,
    @Px int top,
    @Px int right,
    @Px int bottom
)

Updates this drawable's bounds.

Public methods

DrawableKt.toBitmap

@NonNull
public static final Bitmap DrawableKt.toBitmap(
    @NonNull Drawable receiver,
    @Px int width,
    @Px int height,
    @Nullable Bitmap.Config config
)

Return a Bitmap representation of this Drawable.

If this instance is a BitmapDrawable and the width, height, and config match, the underlying Bitmap instance will be returned directly. If any of those three properties differ then a new Bitmap is created. For all other Drawable types, a new Bitmap is created.

Parameters
@Px int width

Width of the desired bitmap. Defaults to Drawable.getIntrinsicWidth.

@Px int height

Height of the desired bitmap. Defaults to Drawable.getIntrinsicHeight.

@Nullable Bitmap.Config config

Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to Config.ARGB_8888 otherwise.

DrawableKt.updateBounds

@NonNull
public static final void DrawableKt.updateBounds(
    @NonNull Drawable receiver,
    @Px int left,
    @Px int top,
    @Px int right,
    @Px int bottom
)

Updates this drawable's bounds. This version of the method allows using named parameters to just set one or more axes.

See also
setBounds