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
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new drawable, creating it by decoding a bitmap from the given input stream.
| |||||||||||
Returns a new drawable by creating it from a bitmap, setting initial target density based on
the display metrics of the resources.
| |||||||||||
Returns a new drawable, creating it by opening a given file path and decoding the bitmap.
| |||||||||||
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
| |||||||||||
Gets the current alpha value for the drawable.
| |||||||||||
Returns the bitmap used by this drawable to render.
| |||||||||||
Returns the current color filter, or
null if none set. | |||||||||||
Get the gravity used to position/stretch the bitmap within its bounds.
| |||||||||||
Return the intrinsic height of the underlying drawable object.
| |||||||||||
Return the intrinsic width of the underlying drawable object.
| |||||||||||
Return the opacity/transparency of this Drawable.
| |||||||||||
Returns the paint used to render this drawable.
| |||||||||||
Indicates whether anti-aliasing is enabled for this drawable.
| |||||||||||
Indicates whether the mipmap hint is enabled on this drawable's bitmap.
| |||||||||||
Specify an alpha value for the drawable.
| |||||||||||
Enables or disables anti-aliasing for this drawable.
| |||||||||||
Specify an optional color filter for the drawable.
| |||||||||||
Sets the corner radius to be applied when drawing the bitmap.
| |||||||||||
Set to true to have the drawable dither its colors when drawn to a device
with fewer than 8-bits per color component.
| |||||||||||
Set to true to have the drawable filter its bitmap when scaled or rotated
(for drawables that use bitmaps).
| |||||||||||
Set the gravity used to position/stretch the bitmap within its bounds.
| |||||||||||
Enables or disables the mipmap hint for this drawable's bitmap.
| |||||||||||
Set the density at which this drawable will be rendered.
| |||||||||||
Set the density scale at which this drawable will be rendered.
| |||||||||||
Set the density scale at which this drawable will be rendered.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.graphics.drawable.Drawable
| |||||||||||
From class
java.lang.Object
|
Returns a new drawable, creating it by decoding a bitmap from the given input stream.
Returns a new drawable by creating it from a bitmap, setting initial target density based on the display metrics of the resources.
Returns a new drawable, creating it by opening a given file path and decoding the bitmap.
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
canvas | The canvas to draw into |
---|
Gets the current alpha value for the drawable. 0 means fully transparent, 255 means fully opaque. This method is implemented by Drawable subclasses and the value returned is specific to how that class treats alpha. The default return value is 255 if the class does not override this method to return a value specific to its use of alpha.
Returns the current color filter, or null
if none set.
null
if none set
Get the gravity used to position/stretch the bitmap within its bounds.
Return the intrinsic height of the underlying drawable object. Returns -1 if it has no intrinsic height, such as with a solid color.
Return the intrinsic width of the underlying drawable object. Returns -1 if it has no intrinsic width, such as with a solid color.
Return the opacity/transparency of this Drawable. The returned value is
one of the abstract format constants in
PixelFormat
:
UNKNOWN
,
TRANSLUCENT
,
TRANSPARENT
, or
OPAQUE
.
Generally a Drawable should be as conservative as possible with the
value it returns. For example, if it contains multiple child drawables
and only shows one of them at a time, if only one of the children is
TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
returned. You can use the method resolveOpacity(int, int)
to perform a
standard reduction of two opacities to the appropriate single output.
Note that the returned value does not take into account a
custom alpha or color filter that has been applied by the client through
the setAlpha(int)
or setColorFilter(ColorFilter)
methods.
Indicates whether anti-aliasing is enabled for this drawable.
Indicates whether the mipmap hint is enabled on this drawable's bitmap.
Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
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.
aa | True if the bitmap should be anti-aliased, false otherwise. |
---|
Specify an optional color filter for the drawable. Pass null
to
remove any existing color filter.
cf | the color filter to apply, or null to remove the
existing color filter
|
---|
Sets the corner radius to be applied when drawing the bitmap.
Set to true to have the drawable dither its colors when drawn to a device with fewer than 8-bits per color component. This can improve the look on those devices, but can also slow down the drawing a little.
Set to true to have the drawable filter its bitmap when scaled or rotated (for drawables that use bitmaps). If the drawable does not use bitmaps, this call is ignored. This can improve the look when scaled or rotated, but also slows down the drawing.
Set the gravity used to position/stretch the bitmap within its bounds.
gravity | the gravity |
---|
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.
mipMap | True if the bitmap should use mipmaps, false otherwise. |
---|
Set the density at which this drawable will be rendered.
density | The density scale for this drawable. |
---|
Set the density scale at which this drawable will be rendered.
metrics | The DisplayMetrics indicating the density scale for this drawable. |
---|
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.
canvas | The Canvas from which the density scale must be obtained. |
---|