Stay organized with collections Save and categorize content based on your preferences.

FitWidthBitmapDrawable

public class FitWidthBitmapDrawable extends Drawable


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 call. Top position of the bitmap can be controlled by setVerticalOffset call or PROPERTY_VERTICAL_OFFSET.

Summary

Public constructors

Public methods

void
draw(Canvas canvas)
int
Bitmap

Returns the bitmap.

Drawable.ConstantState
int

This method is deprecated.

Rect

Returns the Rect used for extracting the bitmap.

int

Returns the current vertical offset.

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

Sets the bitmap.

void
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

From android.graphics.drawable.Drawable
void
boolean
void
final Rect
final void
copyBounds(Rect bounds)
static Drawable
static Drawable
createFromResourceStream(
    Resources res,
    TypedValue value,
    InputStream is,
    String srcName
)
static Drawable
static Drawable
static Drawable
createFromXmlInner(
    Resources r,
    XmlPullParser parser,
    AttributeSet attrs
)
final Rect
Drawable.Callback
int
ColorFilter
Drawable
Rect
void
int
int
int
final int
int
int
Insets
void
boolean
getPadding(Rect padding)
int[]
Region
boolean
void
void
boolean
boolean
boolean
boolean
final boolean
void
void
boolean
onLayoutDirectionChanged(int layoutDirection)
boolean
onLevelChange(int level)
boolean
onStateChange(int[] state)
static int
resolveOpacity(int op1, int op2)
void
scheduleSelf(Runnable what, long when)
void
setAutoMirrored(boolean mirrored)
void
setBounds(int left, int top, int right, int bottom)
final void
void
void
setDither(boolean dither)

This method is deprecated.

void
setFilterBitmap(boolean filter)
void
setHotspot(float x, float y)
void
setHotspotBounds(int left, int top, int right, int bottom)
final boolean
setLayoutDirection(int layoutDirection)
final boolean
setLevel(int level)
boolean
setState(int[] stateSet)
void
setTint(int tintColor)
void
void
void
boolean
setVisible(boolean visible, boolean restart)
void

Constants

PROPERTY_VERTICAL_OFFSET

public static final Property<FitWidthBitmapDrawableIntegerPROPERTY_VERTICAL_OFFSET

Property for setVerticalOffset and getVerticalOffset.

Public constructors

FitWidthBitmapDrawable

public FitWidthBitmapDrawable()

Public methods

draw

public void draw(Canvas canvas)

getAlpha

public int getAlpha()
Returns
int

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

getBitmap

public Bitmap getBitmap()

Returns the bitmap.

getConstantState

public Drawable.ConstantState getConstantState()

getOpacity

public int getOpacity()

getSource

public Rect getSource()

Returns the Rect used for extracting the bitmap.

getVerticalOffset

public int getVerticalOffset()

Returns the current vertical offset.

mutate

public Drawable mutate()

setAlpha

public void setAlpha(int alpha)

setBitmap

public void setBitmap(Bitmap bitmap)

Sets the bitmap.

setColorFilter

public void setColorFilter(ColorFilter colorFilter)

setSource

public void setSource(Rect source)

Sets the Rect used for extracting the bitmap.

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.