belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
RoundedBitmapDrawable
public
abstract
class
RoundedBitmapDrawable
extends Drawable
java.lang.Object | ||
↳ | android.graphics.drawable.Drawable | |
↳ | android.support.v4.graphics.drawable.RoundedBitmapDrawable |
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
Bitmap
object.
Also see the Bitmap
class, which handles the management and
transformation of raw bitmap graphics, and should be used when drawing to a
Canvas
.
Summary
Public methods | |
---|---|
void
|
draw(Canvas canvas)
|
int
|
getAlpha()
|
final
Bitmap
|
getBitmap()
Returns the bitmap used by this drawable to render. |
ColorFilter
|
getColorFilter()
|
float
|
getCornerRadius()
|
int
|
getGravity()
Get the gravity used to position/stretch the bitmap within its bounds. |
int
|
getIntrinsicHeight()
|
int
|
getIntrinsicWidth()
|
int
|
getOpacity()
|
final
Paint
|
getPaint()
Returns the paint used to render this drawable. |
boolean
|
hasAntiAlias()
Indicates whether anti-aliasing is enabled for this drawable. |
boolean
|
hasMipMap()
Indicates whether the mipmap hint is enabled on this drawable's bitmap. |
boolean
|
isCircular()
|
void
|
setAlpha(int alpha)
|
void
|
setAntiAlias(boolean aa)
Enables or disables anti-aliasing for this drawable. |
void
|
setCircular(boolean circular)
Sets the image shape to circular. |
void
|
setColorFilter(ColorFilter cf)
|
void
|
setCornerRadius(float cornerRadius)
Sets the corner radius to be applied when drawing the bitmap. |
void
|
setDither(boolean dither)
|
void
|
setFilterBitmap(boolean filter)
|
void
|
setGravity(int gravity)
Set the gravity used to position/stretch the bitmap within its bounds. |
void
|
setMipMap(boolean mipMap)
Enables or disables the mipmap hint for this drawable's bitmap. |
void
|
setTargetDensity(DisplayMetrics metrics)
Set the density scale at which this drawable will be rendered. |
void
|
setTargetDensity(Canvas canvas)
Set the density scale at which this drawable will be rendered. |
void
|
setTargetDensity(int density)
Set the density at which this drawable will be rendered. |
Protected methods | |
---|---|
void
|
onBoundsChange(Rect bounds)
|
Inherited methods | |
---|---|
From
class
android.graphics.drawable.Drawable
| |
From
class
java.lang.Object
|
Public methods
getAlpha
int getAlpha ()
Returns | |
---|---|
int |
getBitmap
Bitmap getBitmap ()
Returns the bitmap used by this drawable to render. May be null.
Returns | |
---|---|
Bitmap |
getCornerRadius
float getCornerRadius ()
Returns | |
---|---|
float |
The corner radius applied when drawing the bitmap. |
getGravity
int getGravity ()
Get the gravity used to position/stretch the bitmap within its bounds.
Returns | |
---|---|
int |
the gravity applied to the bitmap |
See also:
getIntrinsicHeight
int getIntrinsicHeight ()
Returns | |
---|---|
int |
getIntrinsicWidth
int getIntrinsicWidth ()
Returns | |
---|---|
int |
getPaint
Paint getPaint ()
Returns the paint used to render this drawable.
Returns | |
---|---|
Paint |
hasAntiAlias
boolean hasAntiAlias ()
Indicates whether anti-aliasing is enabled for this drawable.
Returns | |
---|---|
boolean |
True if anti-aliasing is enabled, false otherwise. |
See also:
hasMipMap
boolean hasMipMap ()
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:
isCircular
boolean isCircular ()
Returns | |
---|---|
boolean |
true if the image is circular, else false .
|
setAntiAlias
void setAntiAlias (boolean aa)
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:
setCircular
void setCircular (boolean circular)
Sets the image shape to circular.
This overwrites any calls made to setCornerRadius(float)
so far.
Parameters | |
---|---|
circular |
boolean |
setColorFilter
void setColorFilter (ColorFilter cf)
Parameters | |
---|---|
cf |
ColorFilter |
setCornerRadius
void setCornerRadius (float cornerRadius)
Sets the corner radius to be applied when drawing the bitmap.
Parameters | |
---|---|
cornerRadius |
float |
setFilterBitmap
void setFilterBitmap (boolean filter)
Parameters | |
---|---|
filter |
boolean |
setGravity
void setGravity (int gravity)
Set the gravity used to position/stretch the bitmap within its bounds.
Parameters | |
---|---|
gravity |
int : the gravity |
See also:
setMipMap
void setMipMap (boolean mipMap)
Enables or disables the mipmap hint for this drawable's bitmap.
See setHasMipMap(boolean)
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:
setTargetDensity
void setTargetDensity (DisplayMetrics metrics)
Set the density scale at which this drawable will be rendered.
Parameters | |
---|---|
metrics |
DisplayMetrics : The DisplayMetrics indicating the density scale for this drawable. |
See also:
setTargetDensity
void setTargetDensity (Canvas canvas)
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. |
See also:
setTargetDensity
void setTargetDensity (int density)
Set the density at which this drawable will be rendered.
Parameters | |
---|---|
density |
int : The density scale for this drawable. |
See also: