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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
| |||||||||||
Sets the image shape to circular.
| |||||||||||
Specify an optional color filter for the drawable.
| |||||||||||
Sets the corner radius to be applied when drawing the bitmap.
| |||||||||||
This method is deprecated.
This property is ignored.
| |||||||||||
Set to true to have the drawable filter its bitmaps with bilinear
sampling when they are scaled or rotated.
| |||||||||||
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.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Override this in your subclass to change appearance if you vary based on
the bounds.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.graphics.drawable.Drawable
| |||||||||||
From class
java.lang.Object
|
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
.
An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.
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 necessarily take into account a
custom alpha or color filter that has been applied by the client through
the setAlpha(int)
or setColorFilter(ColorFilter)
methods. Some subclasses,
such as BitmapDrawable
, ColorDrawable
, and GradientDrawable
,
do account for the value of setAlpha(int)
, but the general behavior is dependent
upon the implementation of the subclass.
Indicates whether anti-aliasing is enabled for this drawable.
Indicates whether the mipmap hint is enabled on this drawable's bitmap.
true
if the image is circular, else false
.
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. |
---|
Sets the image shape to circular.
This overwrites any calls made to setCornerRadius(float)
so far.
Specify an optional color filter for the drawable.
If a Drawable has a ColorFilter, each output pixel of the Drawable's drawing contents will be modified by the color filter before it is blended onto the render target of a Canvas.
Pass null
to remove any existing color filter.
Note: Setting a non-null
color
filter disables tint
.
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.
This method is deprecated.
This property is ignored.
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 bitmaps with bilinear sampling when they are scaled or rotated.
This can improve appearance when bitmaps are rotated. If the drawable does not use bitmaps, this call is ignored.
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. |
---|
Override this in your subclass to change appearance if you vary based on the bounds.