public class ReactViewBackgroundDrawable
extends android.graphics.drawable.Drawable
Drawable
used for background of ReactViewGroup
. It supports drawing
background color and borders (including rounded borders) by providing a react friendly API
(setter for each of those properties).
The implementation tries to allocate as few objects as possible depending on which properties
are set. E.g. for views with rounded background/borders we allocate mInnerClipPathForBorderRadius
and mInnerClipTempRectForBorderRadius
. In case when view
have a rectangular borders we allocate mBorderWidthResult
and similar. When only
background color is set we won't allocate any extra/unnecessary objects.
Modifier and Type | Class and Description |
---|---|
static class |
ReactViewBackgroundDrawable.BorderRadiusLocation |
Constructor and Description |
---|
ReactViewBackgroundDrawable(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
void |
draw(android.graphics.Canvas canvas) |
int |
getAlpha() |
float |
getBorderRadius(ReactViewBackgroundDrawable.BorderRadiusLocation location) |
float |
getBorderRadiusOrDefaultTo(float defaultValue,
ReactViewBackgroundDrawable.BorderRadiusLocation location) |
float |
getBorderWidthOrDefaultTo(float defaultValue,
int spacingType) |
int |
getColor() |
android.graphics.RectF |
getDirectionAwareBorderInsets() |
float |
getFullBorderRadius() |
float |
getFullBorderWidth()
For rounded borders we use default "borderWidth" property.
|
int |
getOpacity() |
void |
getOutline(android.graphics.Outline outline) |
int |
getResolvedLayoutDirection()
Similar to Drawable.getLayoutDirection, but available in APIs < 23.
|
boolean |
hasRoundedBorders() |
protected void |
onBoundsChange(android.graphics.Rect bounds) |
boolean |
onResolvedLayoutDirectionChanged(int layoutDirection)
Similar to Drawable.onLayoutDirectionChanged, but available in APIs < 23.
|
void |
setAlpha(int alpha) |
void |
setBorderColor(int position,
float rgb,
float alpha) |
void |
setBorderStyle(java.lang.String style) |
void |
setBorderWidth(int position,
float width) |
void |
setColor(int color) |
void |
setColorFilter(android.graphics.ColorFilter cf) |
void |
setRadius(float radius) |
void |
setRadius(float radius,
int position) |
boolean |
setResolvedLayoutDirection(int layoutDirection)
Similar to Drawable.setLayoutDirection, but available in APIs < 23.
|
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isStateful, isVisible, jumpToCurrentState, mutate, onLayoutDirectionChanged, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setVisible, unscheduleSelf
public ReactViewBackgroundDrawable(android.content.Context context)
public void draw(android.graphics.Canvas canvas)
draw
in class android.graphics.drawable.Drawable
public boolean hasRoundedBorders()
protected void onBoundsChange(android.graphics.Rect bounds)
onBoundsChange
in class android.graphics.drawable.Drawable
public void setAlpha(int alpha)
setAlpha
in class android.graphics.drawable.Drawable
public int getAlpha()
getAlpha
in class android.graphics.drawable.Drawable
public void setColorFilter(android.graphics.ColorFilter cf)
setColorFilter
in class android.graphics.drawable.Drawable
public int getOpacity()
getOpacity
in class android.graphics.drawable.Drawable
public void getOutline(android.graphics.Outline outline)
getOutline
in class android.graphics.drawable.Drawable
public void setBorderWidth(int position, float width)
public void setBorderColor(int position, float rgb, float alpha)
public void setBorderStyle(java.lang.String style)
public void setRadius(float radius)
public void setRadius(float radius, int position)
public float getFullBorderRadius()
public float getBorderRadius(ReactViewBackgroundDrawable.BorderRadiusLocation location)
public float getBorderRadiusOrDefaultTo(float defaultValue, ReactViewBackgroundDrawable.BorderRadiusLocation location)
public void setColor(int color)
public int getResolvedLayoutDirection()
public boolean setResolvedLayoutDirection(int layoutDirection)
public boolean onResolvedLayoutDirectionChanged(int layoutDirection)
public int getColor()
public float getBorderWidthOrDefaultTo(float defaultValue, int spacingType)
public float getFullBorderWidth()
public android.graphics.RectF getDirectionAwareBorderInsets()