Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

FitWidthBitmapDrawable

open class FitWidthBitmapDrawable : Drawable
kotlin.Any
   ↳ android.graphics.drawable.Drawable
   ↳ androidx.leanback.graphics.FitWidthBitmapDrawable

Subclass of Drawable that can be used to draw a bitmap into a region. Bitmap will be scaled to fit the full width of the region and will be aligned to the top left corner. Any region outside the bounds will be clipped during draw(Canvas) call. Top position of the bitmap can be controlled by setVerticalOffset(int) call or PROPERTY_VERTICAL_OFFSET.

Summary

Public constructors

Public methods

open Unit
draw(canvas: Canvas!)

open Int

open Bitmap!

Returns the bitmap.

open ConstantState!

open Int

open Rect!

Returns the Rect used for extracting the bitmap.

open Int

Returns the current vertical offset.

open Drawable!

open Unit
setAlpha(alpha: Int)

open Unit
setBitmap(bitmap: Bitmap!)

Sets the bitmap.

open Unit
setColorFilter(colorFilter: ColorFilter!)

open Unit
setSource(source: Rect!)

Sets the Rect used for extracting the bitmap.

open Unit

Sets the vertical offset which will be used for drawing the bitmap.

Properties

static Property<FitWidthBitmapDrawable!, Int!>!

Property for setVerticalOffset(int) and getVerticalOffset().

Public constructors

<init>

FitWidthBitmapDrawable()

Public methods

draw

open fun draw(canvas: Canvas!): Unit

getAlpha

open fun getAlpha(): Int
Return
Int: Alpha value between 0(inclusive) and 255(inclusive)

getBitmap

open fun getBitmap(): Bitmap!

Returns the bitmap.

getConstantState

open fun getConstantState(): ConstantState!

getOpacity

open fun getOpacity(): Int

getSource

open fun getSource(): Rect!

Returns the Rect used for extracting the bitmap.

getVerticalOffset

open fun getVerticalOffset(): Int

Returns the current vertical offset.

mutate

open fun mutate(): Drawable!

setAlpha

open fun setAlpha(alpha: Int): Unit

setBitmap

open fun setBitmap(bitmap: Bitmap!): Unit

Sets the bitmap.

setColorFilter

open fun setColorFilter(colorFilter: ColorFilter!): Unit

setSource

open fun setSource(source: Rect!): Unit

Sets the Rect used for extracting the bitmap.

setVerticalOffset

open fun setVerticalOffset(offset: Int): Unit

Sets the vertical offset which will be used for drawing the bitmap. The bitmap drawing will start the provided vertical offset.

Properties

PROPERTY_VERTICAL_OFFSET

static val PROPERTY_VERTICAL_OFFSET: Property<FitWidthBitmapDrawable!, Int!>!

Property for setVerticalOffset(int) and getVerticalOffset().