RoundedBitmapDrawable

Added in 1.1.0

abstract class RoundedBitmapDrawable : Drawable


A Drawable that wraps a bitmap and can be drawn with rounded corners. You can create a RoundedBitmapDrawable from a file path, an input stream, or from a android.graphics.Bitmap object.

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

Public functions

Unit
draw(canvas: Canvas)
Int
Bitmap?

Returns the bitmap used by this drawable to render.

ColorFilter!
Float
Int

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

Int
Int
Int

This function is deprecated.

Paint

Returns the paint used to render this drawable.

Boolean

Indicates whether anti-aliasing is enabled for this drawable.

Boolean

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

Boolean
Unit
setAlpha(alpha: Int)
Unit

Enables or disables anti-aliasing for this drawable.

Unit
setCircular(circular: Boolean)

Sets the image shape to circular.

Unit
Unit
setCornerRadius(cornerRadius: Float)

Sets the corner radius to be applied when drawing the bitmap.

Unit
setDither(dither: Boolean)

This function is deprecated.

Unit
Unit
setGravity(gravity: Int)

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

Unit
setMipMap(mipMap: Boolean)

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

Unit

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

Unit

Set the density at which this drawable will be rendered.

Unit

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

Protected functions

Unit

Inherited functions

From android.graphics.drawable.Drawable
Unit
Boolean
Unit
Rect!
Unit
copyBounds(bounds: Rect!)
java-static Drawable!
createFromPath(pathName: String!)
java-static Drawable!
createFromResourceStream(
    res: Resources!,
    value: TypedValue!,
    is: InputStream!,
    srcName: String!
)
java-static Drawable!
createFromStream(is: InputStream!, srcName: String!)
java-static Drawable!
java-static Drawable!
createFromXmlInner(
    r: Resources!,
    parser: XmlPullParser!,
    attrs: AttributeSet!
)
Rect!
Drawable.Callback!
Int
Drawable.ConstantState!
Drawable!
Rect!
Unit
Int
Int
Int
Int
Insets!
Unit
getOutline(outline: Outline!)
Boolean
getPadding(padding: Rect!)
IntArray<Int>!
Region!
Boolean
Unit
inflate(r: Resources!, parser: XmlPullParser!, attrs: AttributeSet!)
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Drawable!
Boolean
onLayoutDirectionChanged(layoutDirection: Int)
Boolean
Boolean
java-static Int
resolveOpacity(op1: Int, op2: Int)
Unit
scheduleSelf(what: Runnable!, when: Long)
Unit
Unit
setBounds(left: Int, top: Int, right: Int, bottom: Int)
Unit
Unit
Unit
Unit
setHotspotBounds(left: Int, top: Int, right: Int, bottom: Int)
Boolean
setLayoutDirection(layoutDirection: Int)
Boolean
setLevel(level: Int)
Boolean
setState(stateSet: IntArray!)
Unit
setTint(tintColor: Int)
Unit
Unit
Unit
Boolean
setVisible(visible: Boolean, restart: Boolean)
Unit

Public functions

draw

Added in 1.1.0
fun draw(canvas: Canvas): Unit

getAlpha

fun getAlpha(): Int

getBitmap

Added in 1.1.0
fun getBitmap(): Bitmap?

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

getColorFilter

fun getColorFilter(): ColorFilter!

getCornerRadius

Added in 1.1.0
fun getCornerRadius(): Float
Returns
Float

The corner radius applied when drawing the bitmap.

getGravity

Added in 1.1.0
fun getGravity(): Int

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

Returns
Int

the gravity applied to the bitmap

See also
Gravity

getIntrinsicHeight

fun getIntrinsicHeight(): Int

getIntrinsicWidth

fun getIntrinsicWidth(): Int

getOpacity

Added in 1.1.0
fun getOpacity(): Int

getPaint

Added in 1.1.0
fun getPaint(): Paint

Returns the paint used to render this drawable.

hasAntiAlias

Added in 1.1.0
fun hasAntiAlias(): Boolean

Indicates whether anti-aliasing is enabled for this drawable.

Returns
Boolean

True if anti-aliasing is enabled, false otherwise.

See also
setAntiAlias

hasMipMap

Added in 1.1.0
fun hasMipMap(): Boolean

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

Returns
Boolean

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

See also
setMipMap

isCircular

Added in 1.1.0
fun isCircular(): Boolean
Returns
Boolean

true if the image is circular, else false.

setAlpha

Added in 1.1.0
fun setAlpha(alpha: Int): Unit

setAntiAlias

Added in 1.1.0
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
hasAntiAlias

setCircular

Added in 1.1.0
fun setCircular(circular: Boolean): Unit

Sets the image shape to circular.

This overwrites any calls made to setCornerRadius so far.

setColorFilter

Added in 1.1.0
fun setColorFilter(cf: ColorFilter!): Unit

setCornerRadius

Added in 1.1.0
fun setCornerRadius(cornerRadius: Float): Unit

Sets the corner radius to be applied when drawing the bitmap.

setDither

Added in 1.1.0
fun setDither(dither: Boolean): Unit

setFilterBitmap

fun setFilterBitmap(filter: Boolean): Unit

setGravity

Added in 1.1.0
fun setGravity(gravity: Int): Unit

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

Parameters
gravity: Int

the gravity

See also
Gravity

setMipMap

Added in 1.1.0
fun setMipMap(mipMap: Boolean): Unit

Enables or disables the mipmap hint for this drawable's bitmap. See setHasMipMap for more information. If the bitmap is null, or the current API version does not support setting a mipmap hint, calling this method has no effect.

Parameters
mipMap: Boolean

True if the bitmap should use mipmaps, false otherwise.

See also
hasMipMap

setTargetDensity

Added in 1.1.0
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 1.1.0
fun setTargetDensity(density: Int): Unit

Set the density at which this drawable will be rendered.

Parameters
density: Int

The density scale for this drawable.

setTargetDensity

Added in 1.1.0
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.

Protected functions

onBoundsChange

protected fun onBoundsChange(bounds: Rect): Unit