Added in API level 1

BitmapDrawable


open class BitmapDrawable : Drawable

A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a android.graphics.Bitmap object.

It can be defined in an XML file with the <bitmap> element. For more information, see the guide to Drawable Resources.

Also see the android.graphics.Bitmap class, which handles the management and transformation of raw bitmap graphics, and should be used when drawing to a android.graphics.Canvas.

Summary

XML attributes
android:antialias Enables or disables antialiasing.
android:dither Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen).
android:filter Enables or disables bitmap filtering.
android:gravity Defines the gravity for the bitmap.
android:mipMap Enables or disables the mipmap hint.
android:src Identifier of the bitmap file.
android:tileMode Defines the tile mode.
Public constructors

Create an empty drawable, not dealing with density.

Create an empty drawable, setting initial target density based on the display metrics of the resources.

BitmapDrawable(res: Resources!, bitmap: Bitmap!)

Create drawable from a bitmap, setting initial target density based on the display metrics of the resources.

Create a drawable by decoding a bitmap from the given input stream.

BitmapDrawable(res: Resources!, filepath: String!)

Create a drawable by opening a given file path and decoding the bitmap.

Create drawable from a bitmap, not dealing with density.

Create a drawable by decoding a bitmap from the given input stream.

BitmapDrawable(filepath: String!)

Create a drawable by opening a given file path and decoding the bitmap.

Public methods
open Unit

open Boolean

open Unit
draw(canvas: Canvas)

open Int

Bitmap!

Returns the bitmap used by this drawable to render.

open Int

Return a mask of the configuration parameters for which this drawable may change, requiring that it be re-created.

open ColorFilter?

Drawable.ConstantState?

open Int

Get the gravity used to position/stretch the bitmap within its bounds.

open Int

open Int

open Int

open Insets

open Unit
getOutline(outline: Outline)

Called to get the drawable to populate the Outline that defines its drawing area.

Paint!

Returns the paint used to render this drawable.

open Shader.TileMode!

Indicates the repeat behavior of this drawable on the X axis.

open Shader.TileMode!

Indicates the repeat behavior of this drawable on the Y axis.

open Boolean

Indicates whether anti-aliasing is enabled for this drawable.

open Boolean

open Boolean

Indicates whether the mipmap hint is enabled on this drawable's bitmap.

open Unit
inflate(r: Resources, parser: XmlPullParser, attrs: AttributeSet, theme: Resources.Theme?)

Boolean

open Boolean

open Boolean

open Drawable

A mutable BitmapDrawable still shares its Bitmap with any other Drawable that comes from the same resource.

open Unit
setAlpha(alpha: Int)

open Unit

Enables or disables anti-aliasing for this drawable.

open Unit

open Unit
setBitmap(bitmap: Bitmap?)

Switch to a new Bitmap object.

open Unit
setColorFilter(colorFilter: ColorFilter?)

open Unit
setDither(dither: Boolean)

open Unit

open Unit
setGravity(gravity: Int)

Set the gravity used to position/stretch the bitmap within its bounds.

open Unit
setMipMap(mipMap: Boolean)

Enables or disables the mipmap hint for this drawable's bitmap.

open Unit

Set the density scale at which this drawable will be rendered.

open Unit

Set the density scale at which this drawable will be rendered.

open Unit

Set the density at which this drawable will be rendered.

open Unit

Sets the repeat behavior of this drawable on the X axis.

open Unit

Sets the repeat behavior of this drawable on both axis.

Unit

Sets the repeat behavior of this drawable on the Y axis.

open Unit

Specifies a tint blending mode for this drawable.

open Unit

Protected methods
open Unit

open Boolean

Inherited functions
Unit clearColorFilter()

Removes the color filter for this drawable.

Rect copyBounds()

Return a copy of the drawable's bounds in a new Rect. This returns the same values as getBounds(), but the returned object is guaranteed to not be changed later by the drawable (i.e. it retains no reference to this rect). If the caller already has a Rect allocated, call copyBounds(rect).

Unit copyBounds(bounds: Rect)

Return a copy of the drawable's bounds in the specified Rect (allocated by the caller). The bounds specify where this will draw when its draw() method is called.

Drawable? createFromPath(pathName: String!)

Create a drawable from file path name.

Drawable? createFromResourceStream(res: Resources?, value: TypedValue?, is: InputStream?, srcName: String?)

Create a drawable from an inputstream, using the given resources and value to determine density information.

Drawable? createFromResourceStream(res: Resources?, value: TypedValue?, is: InputStream?, srcName: String?, opts: BitmapFactory.Options?)

Create a drawable from an inputstream, using the given resources and value to determine density information.

Drawable? createFromStream(is: InputStream?, srcName: String?)

Create a drawable from an inputstream

Drawable createFromXml(r: Resources, parser: XmlPullParser)

Create a drawable from an XML document. For more information on how to create resources in XML, see Drawable Resources.

Drawable createFromXml(r: Resources, parser: XmlPullParser, theme: Resources.Theme?)

Create a drawable from an XML document using an optional Theme. For more information on how to create resources in XML, see Drawable Resources.

Drawable createFromXmlInner(r: Resources, parser: XmlPullParser, attrs: AttributeSet)

Create from inside an XML document. Called on a parser positioned at a tag in an XML document, tries to create a Drawable from that tag. Returns null if the tag is not a valid drawable.

Drawable createFromXmlInner(r: Resources, parser: XmlPullParser, attrs: AttributeSet, theme: Resources.Theme?)

Create a drawable from inside an XML document using an optional Theme. Called on a parser positioned at a tag in an XML document, tries to create a Drawable from that tag. Returns null if the tag is not a valid drawable.

Rect getBounds()

Return the drawable's bounds Rect. Note: for efficiency, the returned object may be the same object stored in the drawable (though this is not guaranteed), so if a persistent copy of the bounds is needed, call copyBounds(rect) instead. You should also not change the object returned by this method as it may be the same object stored in the drawable.

Drawable.Callback? getCallback()

Return the current Callback implementation attached to this Drawable.

Drawable getCurrent()

Rect getDirtyBounds()

Return the drawable's dirty bounds Rect. Note: for efficiency, the returned object may be the same object stored in the drawable (though this is not guaranteed).

By default, this returns the full drawable bounds. Custom drawables may override this method to perform more precise invalidation.

Unit getHotspotBounds(outRect: Rect)

Populates outRect with the hotspot bounds.

Int getLayoutDirection()

Returns the resolved layout direction for this Drawable.

Int getLevel()

Retrieve the current level.

Int getMinimumHeight()

Returns the minimum height suggested by this Drawable. If a View uses this Drawable as a background, it is suggested that the View use at least this value for its height. (There will be some scenarios where this will not be possible.) This value should INCLUDE any padding.

Int getMinimumWidth()

Returns the minimum width suggested by this Drawable. If a View uses this Drawable as a background, it is suggested that the View use at least this value for its width. (There will be some scenarios where this will not be possible.) This value should INCLUDE any padding.

Boolean getPadding(padding: Rect)

Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds. Positive values move toward the center of the Drawable (set Rect.inset).

IntArray getState()

Describes the current state, as a union of primitive states, such as android.R.attr#state_focused, android.R.attr#state_selected, etc. Some drawables may modify their imagery based on the selected state.

Region? getTransparentRegion()

Returns a Region representing the part of the Drawable that is completely transparent. This can be used to perform drawing operations, identifying which parts of the target will not change when rendering the Drawable. The default implementation returns null, indicating no transparent region; subclasses can optionally override this to return an actual Region if they want to supply this optimization information, but it is not required that they do so.

Unit inflate(r: Resources, parser: XmlPullParser, attrs: AttributeSet)

Inflate this Drawable from an XML resource. Does not apply a theme.

Unit invalidateSelf()

Use the current Callback implementation to have this Drawable redrawn. Does nothing if there is no Callback attached to the Drawable.

Boolean isProjected()

Whether this drawable requests projection. Indicates that the android.graphics.RenderNode this Drawable will draw into should be drawn immediately after the closest ancestor RenderNode containing a projection receiver.

Boolean isVisible()

Unit jumpToCurrentState()

If this Drawable does transition animations between states, ask that it immediately jump to the current state and skip any active animations.

Boolean onLayoutDirectionChanged(layoutDirection: Int)

Called when the drawable's resolved layout direction changes.

Boolean onLevelChange(level: Int)

Override this in your subclass to change appearance if you vary based on level.

Int resolveOpacity(op1: Int, op2: Int)

Return the appropriate opacity value for two source opacities. If either is UNKNOWN, that is returned; else, if either is TRANSLUCENT, that is returned; else, if either is TRANSPARENT, that is returned; else, OPAQUE is returned.

This is to help in implementing getOpacity.

Unit scheduleSelf(what: Runnable, when: Long)

Use the current Callback implementation to have this Drawable scheduled. Does nothing if there is no Callback attached to the Drawable.

Unit setBounds(bounds: Rect)

Specify a bounding rectangle for the Drawable. This is where the drawable will draw when its draw() method is called.

Unit setBounds(left: Int, top: Int, right: Int, bottom: Int)

Specify a bounding rectangle for the Drawable. This is where the drawable will draw when its draw() method is called.

Unit setCallback(cb: Drawable.Callback?)

Bind a Callback object to this Drawable. Required for clients that want to support animated drawables.

Unit setChangingConfigurations(configs: Int)

Set a mask of the configuration parameters for which this drawable may change, requiring that it be re-created.

Unit setColorFilter(color: Int, mode: PorterDuff.Mode)

Specify a color and Porter-Duff mode to be the color filter for this drawable.

Convenience for setColorFilter(android.graphics.ColorFilter) which constructs a PorterDuffColorFilter.

Note: Setting a color filter disables tint.

Unit setHotspot(x: Float, y: Float)

Specifies the hotspot's location within the drawable.

Unit setHotspotBounds(left: Int, top: Int, right: Int, bottom: Int)

Sets the bounds to which the hotspot is constrained, if they should be different from the drawable bounds.

Boolean setLayoutDirection(layoutDirection: Int)

Set the layout direction for this drawable. Should be a resolved layout direction, as the Drawable has no capacity to do the resolution on its own.

Boolean setLevel(level: Int)

Specify the level for the drawable. This allows a drawable to vary its imagery based on a continuous controller, for example to show progress or volume level.

If the new level you are supplying causes the appearance of the Drawable to change, then it is responsible for calling invalidateSelf in order to have itself redrawn, and true will be returned from this function.

Boolean setState(stateSet: IntArray)

Specify a set of states for the drawable. These are use-case specific, so see the relevant documentation. As an example, the background for widgets like Button understand the following states: [android.R.attr#state_focused, android.R.attr#state_pressed].

If the new state you are supplying causes the appearance of the Drawable to change, then it is responsible for calling invalidateSelf in order to have itself redrawn, and true will be returned from this function.

Note: The Drawable holds a reference on to stateSet until a new state array is given to it, so you must not modify this array during that time.

Unit setTint(tintColor: Int)

Specifies tint color for this drawable.

A Drawable's drawing content will be blended together with its tint before it is drawn to the screen. This functions similarly to setColorFilter(int,android.graphics.PorterDuff.Mode).

To clear the tint, pass null to setTintList(android.content.res.ColorStateList).

Note: Setting a color filter via setColorFilter(android.graphics.ColorFilter) or setColorFilter(int,android.graphics.PorterDuff.Mode) overrides tint.

Unit setTintMode(tintMode: PorterDuff.Mode?)

Specifies a tint blending mode for this drawable.

Defines how this drawable's tint color should be blended into the drawable before it is drawn to screen. Default tint mode is PorterDuff.Mode.SRC_IN.

Note: Setting a color filter via setColorFilter(android.graphics.ColorFilter) or setColorFilter(int,android.graphics.PorterDuff.Mode) overrides tint.

Boolean setVisible(visible: Boolean, restart: Boolean)

Set whether this Drawable is visible. This generally does not impact the Drawable's behavior, but is a hint that can be used by some Drawables, for example, to decide whether run animations.

Unit unscheduleSelf(what: Runnable)

Use the current Callback implementation to have this Drawable unscheduled. Does nothing if there is no Callback attached to the Drawable.

XML attributes

android:antialias

android:antialias
Enables or disables antialiasing. Antialiasing can be used to smooth the edges of a bitmap when rotated. Default value is false.

May be a boolean value, such as "true" or "false".

android:dither

android:dither
Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen). Default value is true.

May be a boolean value, such as "true" or "false".

android:filter

android:filter
Enables or disables bitmap filtering. Filtering is used when the bitmap is shrunk or stretched to smooth its appearance. Default value is true.

May be a boolean value, such as "true" or "false".

android:gravity

android:gravity
Defines the gravity for the bitmap. The gravity indicates where to position the drawable in its container if the bitmap is smaller than the container.

Must be one or more (separated by '|') of the following constant values.

Constant Value Description
bottom 50 Push object to the bottom of its container, not changing its size.
center 11 Place the object in the center of its container in both the vertical and horizontal axis, not changing its size.
center_horizontal 1 Place object in the horizontal center of its container, not changing its size.
center_vertical 10 Place object in the vertical center of its container, not changing its size.
clip_horizontal 8 Additional option that can be set to have the left and/or right edges of the child clipped to its container's bounds. The clip will be based on the horizontal gravity: a left gravity will clip the right edge, a right gravity will clip the left edge, and neither will clip both edges.
clip_vertical 80 Additional option that can be set to have the top and/or bottom edges of the child clipped to its container's bounds. The clip will be based on the vertical gravity: a top gravity will clip the bottom edge, a bottom gravity will clip the top edge, and neither will clip both edges.
end 800005 Push object to the end of its container, not changing its size.
fill 77 Grow the horizontal and vertical size of the object if needed so it completely fills its container.
fill_horizontal 7 Grow the horizontal size of the object if needed so it completely fills its container.
fill_vertical 70 Grow the vertical size of the object if needed so it completely fills its container.
left 3 Push object to the left of its container, not changing its size.
right 5 Push object to the right of its container, not changing its size.
start 800003 Push object to the beginning of its container, not changing its size.
top 30 Push object to the top of its container, not changing its size.

android:mipMap

android:mipMap
Enables or disables the mipmap hint. See android.graphics.Bitmap#setHasMipMap(boolean) for more information. Default value is false.

May be a boolean value, such as "true" or "false".

android:src

android:src
Identifier of the bitmap file. This attribute is mandatory.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

May be a color value, in the form of "rgb", "argb", "rrggbb", or "aarrggbb".

android:tileMode

android:tileMode
Defines the tile mode. When the tile mode is enabled, the bitmap is repeated. Gravity is ignored when the tile mode is enabled. Default value is "disabled".

Must be one of the following constant values.

Constant Value Description
clamp 0 Replicates the edge color.
disabled ffffffff Do not tile the bitmap. This is the default value.
mirror 2 Repeats the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
repeat 1 Repeats the bitmap in both direction.

Public constructors

BitmapDrawable

Added in API level 1
BitmapDrawable()

Deprecated: Use BitmapDrawable(android.content.res.Resources,android.graphics.Bitmap) instead to specify a bitmap to draw with and ensure the correct density is set.

Create an empty drawable, not dealing with density.

BitmapDrawable

Added in API level 4
BitmapDrawable(res: Resources!)

Deprecated: Use BitmapDrawable(android.content.res.Resources,android.graphics.Bitmap) instead to specify a bitmap to draw with.

Create an empty drawable, setting initial target density based on the display metrics of the resources.

BitmapDrawable

Added in API level 4
BitmapDrawable(
    res: Resources!,
    bitmap: Bitmap!)

Create drawable from a bitmap, setting initial target density based on the display metrics of the resources.

BitmapDrawable

Added in API level 5
BitmapDrawable(
    res: Resources!,
    is: InputStream!)

Create a drawable by decoding a bitmap from the given input stream.

BitmapDrawable

Added in API level 5
BitmapDrawable(
    res: Resources!,
    filepath: String!)

Create a drawable by opening a given file path and decoding the bitmap.

BitmapDrawable

Added in API level 1
BitmapDrawable(bitmap: Bitmap!)

Deprecated: Use BitmapDrawable(android.content.res.Resources,android.graphics.Bitmap) to ensure that the drawable has correctly set its target density.

Create drawable from a bitmap, not dealing with density.

BitmapDrawable

Added in API level 1
BitmapDrawable(is: InputStream!)

Deprecated: Use BitmapDrawable(android.content.res.Resources,java.io.InputStream) to ensure that the drawable has correctly set its target density.

Create a drawable by decoding a bitmap from the given input stream.

BitmapDrawable

Added in API level 1
BitmapDrawable(filepath: String!)

Deprecated: Use BitmapDrawable(android.content.res.Resources,java.lang.String) to ensure that the drawable has correctly set its target density.

Create a drawable by opening a given file path and decoding the bitmap.

Public methods

applyTheme

Added in API level 21
open fun applyTheme(t: Resources.Theme): Unit
Parameters
t Resources.Theme: the theme to apply This value cannot be null.

canApplyTheme

Added in API level 21
open fun canApplyTheme(): Boolean

draw

Added in API level 1
open fun draw(canvas: Canvas): Unit
Parameters
canvas Canvas: The canvas to draw into This value cannot be null.

getAlpha

Added in API level 19
open fun getAlpha(): Int
Return
Int Value is between 0 and 255 inclusive

getBitmap

Added in API level 1
fun getBitmap(): Bitmap!

Returns the bitmap used by this drawable to render. May be null.

getColorFilter

Added in API level 21
open fun getColorFilter(): ColorFilter?
Return
ColorFilter? the current color filter, or null if none set

getConstantState

Added in API level 1
fun getConstantState(): Drawable.ConstantState?
Return
Drawable.ConstantState? The ConstantState associated to that Drawable. This value may be null.

getGravity

Added in API level 1
open fun getGravity(): Int

Get the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity

Return
Int the gravity applied to the bitmap

getIntrinsicHeight

Added in API level 1
open fun getIntrinsicHeight(): Int
Return
Int the intrinsic height, or -1 if no intrinsic height

getIntrinsicWidth

Added in API level 1
open fun getIntrinsicWidth(): Int
Return
Int the intrinsic width, or -1 if no intrinsic width

getOpacity

Added in API level 1
open fun getOpacity(): Int

getOpticalInsets

Added in API level 29
open fun getOpticalInsets(): Insets
Return
Insets This value cannot be null.

getOutline

Added in API level 21
open fun getOutline(outline: Outline): Unit

Called to get the drawable to populate the Outline that defines its drawing area.

This method is called by the default android.view.ViewOutlineProvider to define the outline of the View.

The default behavior defines the outline to be the bounding rectangle of 0 alpha. Subclasses that wish to convey a different shape or alpha value must override this method.

Parameters
outline Outline: This value cannot be null.

getPaint

Added in API level 1
fun getPaint(): Paint!

Returns the paint used to render this drawable.

getTileModeX

Added in API level 1
open fun getTileModeX(): Shader.TileMode!

Indicates the repeat behavior of this drawable on the X axis.

getTileModeY

Added in API level 1
open fun getTileModeY(): Shader.TileMode!

Indicates the repeat behavior of this drawable on the Y axis.

hasAntiAlias

Added in API level 18
open fun hasAntiAlias(): Boolean

Indicates whether anti-aliasing is enabled for this drawable.

Return
Boolean True if anti-aliasing is enabled, false otherwise.

hasFocusStateSpecified

Added in API level 31
open fun hasFocusStateSpecified(): Boolean
Return
Boolean true if android.R.attr#state_focused is specified for this drawable.

hasMipMap

Added in API level 18
open fun hasMipMap(): Boolean

Indicates whether the mipmap hint is enabled on this drawable's bitmap.

Return
Boolean True if the mipmap hint is set, false otherwise. If the bitmap is null, this method always returns false.

inflate

Added in API level 21
open fun inflate(
    r: Resources,
    parser: XmlPullParser,
    attrs: AttributeSet,
    theme: Resources.Theme?
): Unit
Parameters
r Resources: Resources used to resolve attribute values This value cannot be null.
parser XmlPullParser: XML parser from which to inflate this Drawable This value cannot be null.
attrs AttributeSet: Base set of attribute values This value cannot be null.
theme Resources.Theme?: Theme to apply, may be null
Exceptions
org.xmlpull.v1.XmlPullParserException
java.io.IOException

isAutoMirrored

Added in API level 19
fun isAutoMirrored(): Boolean
Return
Boolean boolean Returns true if this Drawable will be automatically mirrored.

isFilterBitmap

Added in API level 23
open fun isFilterBitmap(): Boolean
Return
Boolean whether this drawable filters its bitmaps

isStateful

Added in API level 1
open fun isStateful(): Boolean
Return
Boolean True if this drawable changes its appearance based on state, false otherwise.

mutate

Added in API level 3
open fun mutate(): Drawable

A mutable BitmapDrawable still shares its Bitmap with any other Drawable that comes from the same resource.

Return
Drawable This drawable.

setAlpha

Added in API level 1
open fun setAlpha(alpha: Int): Unit
Parameters
alpha Int: Value is between 0 and 255 inclusive

setAntiAlias

Added in API level 1
open fun setAntiAlias(aa: Boolean): Unit

Enables or disables anti-aliasing for this drawable. Anti-aliasing affects the edges of the bitmap only so it applies only when the drawable is rotated.

Parameters
aa Boolean: True if the bitmap should be anti-aliased, false otherwise.

See Also

setAutoMirrored

Added in API level 19
open fun setAutoMirrored(mirrored: Boolean): Unit
Parameters
mirrored Boolean: Set to true if the Drawable should be mirrored, false if not.

setBitmap

Added in API level 31
open fun setBitmap(bitmap: Bitmap?): Unit

Switch to a new Bitmap object.

Parameters
bitmap Bitmap?: This value may be null.

setColorFilter

Added in API level 1
open fun setColorFilter(colorFilter: ColorFilter?): Unit
Parameters
colorFilter ColorFilter?: The color filter to apply, or null to remove the existing color filter

setDither

Added in API level 1
open fun setDither(dither: Boolean): Unit

setFilterBitmap

Added in API level 1
open fun setFilterBitmap(filter: Boolean): Unit

setGravity

Added in API level 1
open fun setGravity(gravity: Int): Unit

Set the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity

Parameters
gravity Int: the gravity

setMipMap

Added in API level 18
open fun setMipMap(mipMap: Boolean): Unit

Enables or disables the mipmap hint for this drawable's bitmap. See Bitmap.setHasMipMap(boolean) for more information. If the bitmap is null calling this method has no effect.

Parameters
mipMap Boolean: True if the bitmap should use mipmaps, false otherwise.

See Also

setTargetDensity

Added in API level 4
open fun setTargetDensity(canvas: Canvas!): Unit

Set the density scale at which this drawable will be rendered. This method assumes the drawable will be rendered at the same density as the specified canvas.

Parameters
canvas Canvas!: The Canvas from which the density scale must be obtained.

setTargetDensity

Added in API level 4
open fun setTargetDensity(metrics: DisplayMetrics!): Unit

Set the density scale at which this drawable will be rendered.

Parameters
metrics DisplayMetrics!: The DisplayMetrics indicating the density scale for this drawable.

setTargetDensity

Added in API level 4
open fun setTargetDensity(density: Int): Unit

Set the density at which this drawable will be rendered.

Parameters
density Int: The density scale for this drawable.

setTileModeX

Added in API level 1
open fun setTileModeX(mode: Shader.TileMode!): Unit

Sets the repeat behavior of this drawable on the X axis. By default, the drawable does not repeat its bitmap. Using android.graphics.Shader.TileMode#REPEAT or android.graphics.Shader.TileMode#MIRROR the bitmap can be repeated (or tiled) if the bitmap is smaller than this drawable.

Parameters
mode Shader.TileMode!: The repeat mode for this drawable.

setTileModeXY

Added in API level 1
open fun setTileModeXY(
    xmode: Shader.TileMode!,
    ymode: Shader.TileMode!
): Unit

Sets the repeat behavior of this drawable on both axis. By default, the drawable does not repeat its bitmap. Using android.graphics.Shader.TileMode#REPEAT or android.graphics.Shader.TileMode#MIRROR the bitmap can be repeated (or tiled) if the bitmap is smaller than this drawable.

Parameters
xmode Shader.TileMode!: The X repeat mode for this drawable.
ymode Shader.TileMode!: The Y repeat mode for this drawable.

setTileModeY

Added in API level 1
fun setTileModeY(mode: Shader.TileMode!): Unit

Sets the repeat behavior of this drawable on the Y axis. By default, the drawable does not repeat its bitmap. Using android.graphics.Shader.TileMode#REPEAT or android.graphics.Shader.TileMode#MIRROR the bitmap can be repeated (or tiled) if the bitmap is smaller than this drawable.

Parameters
mode Shader.TileMode!: The repeat mode for this drawable.

setTintBlendMode

Added in API level 29
open fun setTintBlendMode(blendMode: BlendMode!): Unit

Specifies a tint blending mode for this drawable.

Defines how this drawable's tint color should be blended into the drawable before it is drawn to screen. Default tint mode is BlendMode.SRC_IN.

Note: Setting a color filter via setColorFilter(android.graphics.ColorFilter)

Parameters
blendMode BlendMode!: This value cannot be null.

setTintList

Added in API level 21
open fun setTintList(tint: ColorStateList?): Unit
Parameters
tint ColorStateList?: Color state list to use for tinting this drawable, or null to clear the tint

Protected methods

onBoundsChange

Added in API level 1
protected open fun onBoundsChange(bounds: Rect): Unit
Parameters
bounds Rect: This value cannot be null.

onStateChange

Added in API level 1
protected open fun onStateChange(stateSet: IntArray): Boolean
Parameters
state This value cannot be null.
Return
Boolean Returns true if the state change has caused the appearance of the Drawable to change (that is, it needs to be drawn), else false if it looks the same and there is no need to redraw it since its last state.