-
public class ReactViewBackgroundDrawable extends Drawable
A subclass of 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
{@code * mInnerClipPathForBorderRadius}
and{@code mInnerClipTempRectForBorderRadius}
. In case when view have a rectangular borders we allocate{@code mBorderWidthResult}
and similar. When only background color is set we won't allocate any extra/unnecessary objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
ReactViewBackgroundDrawable.BorderRadiusLocation
-
Constructor Summary
Constructors Constructor Description ReactViewBackgroundDrawable(Context context)
-
Method Summary
Modifier and Type Method Description void
draw(Canvas canvas)
boolean
hasRoundedBorders()
void
setAlpha(int alpha)
int
getAlpha()
void
setColorFilter(ColorFilter cf)
int
getOpacity()
void
getOutline(Outline outline)
void
setBorderWidth(int position, float width)
void
setBorderColor(int position, float rgb, float alpha)
void
setBorderStyle(@Nullable() String style)
void
setRadius(float radius)
void
setRadius(float radius, int position)
float
getFullBorderRadius()
float
getBorderRadius(ReactViewBackgroundDrawable.BorderRadiusLocation location)
float
getBorderRadiusOrDefaultTo(float defaultValue, ReactViewBackgroundDrawable.BorderRadiusLocation location)
void
setColor(int color)
int
getResolvedLayoutDirection()
Similar to Drawable.getLayoutDirection, but available in APIs < 23. boolean
setResolvedLayoutDirection(int layoutDirection)
Similar to Drawable.setLayoutDirection, but available in APIs < 23. boolean
onResolvedLayoutDirectionChanged(int layoutDirection)
Similar to Drawable.onLayoutDirectionChanged, but available in APIs < 23. int
getColor()
float
getBorderWidthOrDefaultTo(float defaultValue, int spacingType)
float
getFullBorderWidth()
For rounded borders we use default "borderWidth" property. int
getBorderColor(int position)
RectF
getDirectionAwareBorderInsets()
-
Methods inherited from class android.graphics.drawable.Drawable
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, draw, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpacity, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, hasFocusStateSpecified, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, onLayoutDirectionChanged, resolveOpacity, scheduleSelf, setAlpha, setAutoMirrored, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintBlendMode, setTintList, setTintMode, setVisible, unscheduleSelf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ReactViewBackgroundDrawable
ReactViewBackgroundDrawable(Context context)
-
-
Method Detail
-
hasRoundedBorders
boolean hasRoundedBorders()
-
setAlpha
void setAlpha(int alpha)
-
getAlpha
int getAlpha()
-
setColorFilter
void setColorFilter(ColorFilter cf)
-
getOpacity
int getOpacity()
-
getOutline
void getOutline(Outline outline)
-
setBorderWidth
void setBorderWidth(int position, float width)
-
setBorderColor
void setBorderColor(int position, float rgb, float alpha)
-
setBorderStyle
void setBorderStyle(@Nullable() String style)
-
setRadius
void setRadius(float radius)
-
setRadius
void setRadius(float radius, int position)
-
getFullBorderRadius
float getFullBorderRadius()
-
getBorderRadius
float getBorderRadius(ReactViewBackgroundDrawable.BorderRadiusLocation location)
-
getBorderRadiusOrDefaultTo
float getBorderRadiusOrDefaultTo(float defaultValue, ReactViewBackgroundDrawable.BorderRadiusLocation location)
-
setColor
void setColor(int color)
-
getResolvedLayoutDirection
int getResolvedLayoutDirection()
Similar to Drawable.getLayoutDirection, but available in APIs < 23.
-
setResolvedLayoutDirection
boolean setResolvedLayoutDirection(int layoutDirection)
Similar to Drawable.setLayoutDirection, but available in APIs < 23.
-
onResolvedLayoutDirectionChanged
boolean onResolvedLayoutDirectionChanged(int layoutDirection)
Similar to Drawable.onLayoutDirectionChanged, but available in APIs < 23.
-
getColor
int getColor()
-
getBorderWidthOrDefaultTo
float getBorderWidthOrDefaultTo(float defaultValue, int spacingType)
-
getFullBorderWidth
float getFullBorderWidth()
For rounded borders we use default "borderWidth" property.
-
getBorderColor
int getBorderColor(int position)
-
getDirectionAwareBorderInsets
RectF getDirectionAwareBorderInsets()
-
-
-
-