public class StyledCornersBitmapDrawable extends ExtendedBitmapDrawable
CORNER_STYLE_SHARP
,
CORNER_STYLE_ROUND
, or CORNER_STYLE_FLAP
.
This is accomplished applying a non-rectangular clip applied to the canvas.
A border is draw that conforms to the styled corners.
CORNER_STYLE_FLAP
corners have a colored flap drawn within the bounds.ExtendedBitmapDrawable.ExtendedOptions
Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
static int |
CORNER_STYLE_FLAP |
static int |
CORNER_STYLE_ROUND |
static int |
CORNER_STYLE_SHARP |
DEBUG, LOAD_STATE_FAILED, LOAD_STATE_LOADED, LOAD_STATE_LOADING, LOAD_STATE_NOT_YET_LOADED, LOAD_STATE_UNINITIALIZED
mCurrKey, mDecodeHeight, mDecodeWidth, mPaint, mPrevKey
Constructor and Description |
---|
StyledCornersBitmapDrawable(Resources res,
BitmapCache cache,
boolean limitDensity,
ExtendedBitmapDrawable.ExtendedOptions opts,
float cornerRoundRadius,
float cornerFlapSide)
Create a new StyledCornersBitmapDrawable.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas)
Override draw(android.graphics.Canvas) instead of
ExtendedBitmapDrawable.onDraw(android.graphics.Canvas) to clip all the drawable layers. |
protected void |
drawFakeCornersForCompatibilityMode(Canvas canvas) |
int |
getFlapColor()
Get the flap color for all corners that have style
CORNER_STYLE_SHARP . |
int |
getScrimColor()
Get the color of the scrim that is drawn over the contents, but under the flaps and borders.
|
void |
invalidateSelf()
Use the current
Drawable.Callback implementation to have this Drawable
redrawn. |
protected void |
onBoundsChange(Rect bounds)
Override this in your subclass to change appearance if you vary based on
the bounds.
|
void |
onLayoutDirectionChangeLocal(int layoutDirection)
Called when the drawable's resolved layout direction changes.
|
void |
setBorderColor(int color)
Set the border stroke color of this drawable.
|
void |
setBorderWidth(float borderWidth)
Set the border stroke width of this drawable.
|
void |
setCompatibilityMode(boolean isCompatibilityMode)
Sets whether we should work around an issue introduced in Android 4.4.3,
where a WebView can corrupt the stencil buffer of the canvas when the canvas is clipped
using a non-rectangular Path.
|
void |
setCompatibilityModeBackgroundColor(int color)
Sets the color of the container that this drawable is in.
|
void |
setCornerStylesRelative(int topStart,
int topEnd,
int bottomEnd,
int bottomStart)
Set the corner styles for all four corners specified in RTL friendly ways
|
void |
setFlapColor(int flapColor)
Set the flap color for all corners that have style
CORNER_STYLE_SHARP . |
void |
setScrimColor(int color)
Set the color of the scrim that is drawn over the contents, but under the flaps and borders.
|
getDecodeHorizontalCenter, getDecodeVerticalCenter, getDrawVerticalCenter, getDrawVerticalOffsetMultiplier, getExtendedOptions, getLoadState, loadFileDescriptorFactory, onBecomeFirstExpected, onDecodeBegin, onDecodeCancel, onDecodeComplete, onDecodeFailed, onDraw, onDrawPlaceholderOrProgress, onOptsChanged, run, setAlpha, setBitmap, setColorFilter, setDecodeDimensions, setExactDecodeDimensions, setImage, setParallaxFraction, shouldExecuteStateChange, showStaticPlaceholder
bind, decode, fileDescriptorFactoryCreated, getBitmap, getDecodeStrategy, getExecutor, getKey, getLayoutDirectionLocal, getOpacity, getPreviousKey, hasBitmap, invalidateDrawable, onDrawBitmap, scheduleDrawable, setLayoutDirectionLocal, unbind, unbind, unscheduleDrawable
applyTheme, canApplyTheme, clearColorFilter, clearMutated, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, obtainAttributes, onLayoutDirectionChanged, onLevelChange, onStateChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setVisible, setXfermode, unscheduleSelf
public static final int CORNER_STYLE_SHARP
public static final int CORNER_STYLE_ROUND
public static final int CORNER_STYLE_FLAP
public StyledCornersBitmapDrawable(Resources res, BitmapCache cache, boolean limitDensity, ExtendedBitmapDrawable.ExtendedOptions opts, float cornerRoundRadius, float cornerFlapSide)
public void setBorderWidth(float borderWidth)
public void setBorderColor(int color)
Color.TRANSPARENT
to disable.public void setCornerStylesRelative(int topStart, int topEnd, int bottomEnd, int bottomStart)
public void onLayoutDirectionChangeLocal(int layoutDirection)
BasicBitmapDrawable
onLayoutDirectionChangeLocal
in class BasicBitmapDrawable
layoutDirection
- the new resolved layout directionpublic int getFlapColor()
CORNER_STYLE_SHARP
.public void setFlapColor(int flapColor)
CORNER_STYLE_SHARP
.
Use Color.TRANSPARENT
to disable flap colors.public int getScrimColor()
public void setScrimColor(int color)
Color.TRANSPARENT
to disable the scrim.public void setCompatibilityMode(boolean isCompatibilityMode)
public void setCompatibilityModeBackgroundColor(int color)
compatibility mode
to draw fake corners to emulate clipped
corners.protected void onBoundsChange(Rect bounds)
Drawable
onBoundsChange
in class ExtendedBitmapDrawable
public void draw(Canvas canvas)
ExtendedBitmapDrawable.onDraw(android.graphics.Canvas)
to clip all the drawable layers.draw
in class ExtendedBitmapDrawable
canvas
- The canvas to draw intopublic void invalidateSelf()
Drawable
Drawable.Callback
implementation to have this Drawable
redrawn. Does nothing if there is no Callback attached to the
Drawable.protected void drawFakeCornersForCompatibilityMode(Canvas canvas)