-
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 enumReactViewBackgroundDrawable.BorderRadiusLocation
-
Constructor Summary
Constructors Constructor Description ReactViewBackgroundDrawable(Context context)
-
Method Summary
Modifier and Type Method Description voiddraw(Canvas canvas)booleanhasRoundedBorders()voidsetAlpha(int alpha)intgetAlpha()voidsetColorFilter(ColorFilter cf)intgetOpacity()voidgetOutline(Outline outline)voidsetBorderWidth(int position, float width)voidsetBorderColor(int position, float rgb, float alpha)voidsetBorderStyle(@Nullable() String style)voidsetRadius(float radius)voidsetRadius(float radius, int position)floatgetFullBorderRadius()floatgetBorderRadius(ReactViewBackgroundDrawable.BorderRadiusLocation location)floatgetBorderRadiusOrDefaultTo(float defaultValue, ReactViewBackgroundDrawable.BorderRadiusLocation location)voidsetColor(int color)intgetResolvedLayoutDirection()Similar to Drawable.getLayoutDirection, but available in APIs < 23. booleansetResolvedLayoutDirection(int layoutDirection)Similar to Drawable.setLayoutDirection, but available in APIs < 23. booleanonResolvedLayoutDirectionChanged(int layoutDirection)Similar to Drawable.onLayoutDirectionChanged, but available in APIs < 23. intgetColor()floatgetBorderWidthOrDefaultTo(float defaultValue, int spacingType)floatgetFullBorderWidth()For rounded borders we use default "borderWidth" property. intgetBorderColor(int position)RectFgetDirectionAwareBorderInsets()-
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()
-
-
-
-