androidx.core.graphics.drawable
Classes
DrawableCompat |
Helper for accessing features in |
IconCompat |
Helper for accessing features in |
RoundedBitmapDrawable |
A Drawable that wraps a bitmap and can be drawn with rounded corners. |
RoundedBitmapDrawableFactory |
Constructs |
Extension functions summary
inline Icon |
@RequiresApi(value = 26) |
Bitmap |
|
Bitmap? |
Drawable.toBitmapOrNull(Returns a |
inline ColorDrawable |
Create a |
inline ColorDrawable |
@RequiresApi(value = 26)Create a |
inline BitmapDrawable |
Bitmap.toDrawable(resources: Resources)Create a |
inline Icon |
@RequiresApi(value = 26) |
inline Icon |
@RequiresApi(value = 26) |
inline Icon |
@RequiresApi(value = 26) |
Unit |
Updates this drawable's bounds. |
Extension functions
Bitmap.toAdaptiveIcon
@RequiresApi(value = 26)
inline fun Bitmap.toAdaptiveIcon(): Icon
Create an Icon from this adaptive Bitmap.
| See also | |
|---|---|
createWithAdaptiveBitmap |
Drawable.toBitmap
fun Drawable.toBitmap(
width: @Px Int = intrinsicWidth,
height: @Px Int = intrinsicHeight,
config: Bitmap.Config? = null
): Bitmap
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 | |
|---|---|
width: @Px Int = intrinsicWidth |
Width of the desired bitmap. Defaults to |
height: @Px Int = intrinsicHeight |
Height of the desired bitmap. Defaults to |
config: Bitmap.Config? = null |
Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to |
| Throws | |
|---|---|
IllegalArgumentException |
if the underlying drawable is a |
| See also | |
|---|---|
toBitmapOrNull |
Drawable.toBitmapOrNull
fun Drawable.toBitmapOrNull(
width: @Px Int = intrinsicWidth,
height: @Px Int = intrinsicHeight,
config: Bitmap.Config? = null
): Bitmap?
Returns a Bitmap representation of this Drawable or null if the drawable cannot be represented as a bitmap.
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.
If the result of BitmapDrawable.getBitmap is null or the drawable cannot otherwise be represented as a bitmap, returns null.
| Parameters | |
|---|---|
width: @Px Int = intrinsicWidth |
Width of the desired bitmap. Defaults to |
height: @Px Int = intrinsicHeight |
Height of the desired bitmap. Defaults to |
config: Bitmap.Config? = null |
Bitmap config of the desired bitmap. Null attempts to use the native config, if any. Defaults to |
| See also | |
|---|---|
toBitmap |
Int.toDrawable
inline fun @ColorInt Int.toDrawable(): ColorDrawable
Create a ColorDrawable from this color value.
Color.toDrawable
@RequiresApi(value = 26)
inline fun Color.toDrawable(): ColorDrawable
Create a ColorDrawable from this Color (via Color.toArgb).
Bitmap.toDrawable
inline fun Bitmap.toDrawable(resources: Resources): BitmapDrawable
Create a BitmapDrawable from this Bitmap.
Bitmap.toIcon
@RequiresApi(value = 26)
inline fun Bitmap.toIcon(): Icon
Create an Icon from this Bitmap.
| See also | |
|---|---|
createWithBitmap |
ByteArray.toIcon
@RequiresApi(value = 26)
inline fun ByteArray.toIcon(): Icon
Create an Icon from this ByteArray.
| See also | |
|---|---|
createWithData |
Drawable.updateBounds
fun Drawable.updateBounds(
left: @Px Int = bounds.left,
top: @Px Int = bounds.top,
right: @Px Int = bounds.right,
bottom: @Px Int = bounds.bottom
): Unit
Updates this drawable's bounds. This version of the method allows using named parameters to just set one or more axes.
| See also | |
|---|---|
setBounds |