Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
Android 0.0.0 Developer Preview
belongs to Maven artifact androidx.leanback:leanback:1.1.0-alpha01

FitWidthBitmapDrawable

public class FitWidthBitmapDrawable
extends Drawable

java.lang.Object
   ↳ 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

Fields

public static final Property<FitWidthBitmapDrawable, Integer> PROPERTY_VERTICAL_OFFSET

Property for setVerticalOffset(int) and getVerticalOffset().

Public constructors

FitWidthBitmapDrawable()

Public methods

void draw(Canvas canvas)
int getAlpha()
Bitmap getBitmap()

Returns the bitmap.

Drawable.ConstantState getConstantState()
int getOpacity()
Rect getSource()

Returns the Rect used for extracting the bitmap.

int getVerticalOffset()

Returns the current vertical offset.

Drawable mutate()
void setAlpha(int alpha)
void setBitmap(Bitmap bitmap)

Sets the bitmap.

void setColorFilter(ColorFilter colorFilter)
void setSource(Rect source)

Sets the Rect used for extracting the bitmap.

void setVerticalOffset(int offset)

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

Inherited methods

Fields

PROPERTY_VERTICAL_OFFSET

public static final Property<FitWidthBitmapDrawable, Integer> PROPERTY_VERTICAL_OFFSET

Property for setVerticalOffset(int) and getVerticalOffset().

Public constructors

FitWidthBitmapDrawable

public FitWidthBitmapDrawable ()

Public methods

draw

public void draw (Canvas canvas)

Parameters
canvas Canvas

getAlpha

public int getAlpha ()

Returns
int Alpha value between 0(inclusive) and 255(inclusive)

getBitmap

public Bitmap getBitmap ()

Returns the bitmap.

Returns
Bitmap

getConstantState

public Drawable.ConstantState getConstantState ()

Returns
Drawable.ConstantState

getOpacity

public int getOpacity ()

Returns
int

getSource

public Rect getSource ()

Returns the Rect used for extracting the bitmap.

Returns
Rect

getVerticalOffset

public int getVerticalOffset ()

Returns the current vertical offset.

Returns
int

mutate

public Drawable mutate ()

Returns
Drawable

setAlpha

public void setAlpha (int alpha)

Parameters
alpha int

setBitmap

public void setBitmap (Bitmap bitmap)

Sets the bitmap.

Parameters
bitmap Bitmap

setColorFilter

public void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setSource

public void setSource (Rect source)

Sets the Rect used for extracting the bitmap.

Parameters
source Rect

setVerticalOffset

public void setVerticalOffset (int offset)

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

Parameters
offset int