Class DynamicDrawableUtils
- java.lang.Object
-
- com.pranavpandey.android.dynamic.util.DynamicDrawableUtils
-
public class DynamicDrawableUtils extends java.lang.ObjectHelper class to performDrawableoperations.
-
-
Constructor Summary
Constructors Constructor Description DynamicDrawableUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, boolean wrap, int color)Colorize and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, boolean wrap, int color, android.graphics.PorterDuff.Mode mode)Colorize and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, boolean wrap, android.graphics.ColorFilter colorFilter)Apply color filter and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, int color)Colorize and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, int color, android.graphics.PorterDuff.Mode mode)Colorize and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablecolorizeDrawable(android.graphics.drawable.Drawable drawable, android.graphics.ColorFilter colorFilter)Apply color filter and return the mutated drawable so that, all other references do not change.static android.graphics.drawable.DrawablegetCornerDrawable(float cornerRadius)Get a gradient drawable according to the corner radius.static android.graphics.drawable.DrawablegetCornerDrawable(float cornerRadius, int color)Get a gradient drawable according to the corner radius.static android.graphics.drawable.DrawablegetCornerDrawable(int width, int height, float cornerRadius)Get a gradient drawable according to the corner radius.static android.graphics.drawable.DrawablegetCornerDrawable(int width, int height, float cornerRadius, int color)Get a gradient drawable according to the corner radius.static android.graphics.drawable.DrawablegetCornerDrawable(int width, int height, android.graphics.drawable.GradientDrawable drawable)Get a gradient drawable according to the supplied drawable.static android.graphics.drawable.DrawablegetCornerDrawable(int width, int height, android.graphics.drawable.GradientDrawable drawable, int color)Get a gradient drawable according to the supplied drawable.static android.graphics.drawable.DrawablegetCornerDrawable(android.graphics.drawable.GradientDrawable drawable)Get a gradient drawable according to the supplied drawable.static android.graphics.drawable.DrawablegetCornerDrawable(android.graphics.drawable.GradientDrawable drawable, int color)Get a gradient drawable according to the supplied drawable.static voidsetBackground(android.view.View view, android.graphics.drawable.Drawable drawable)Set background of a given view in an efficient way by detecting the Android SDK at runtime.
-
-
-
Method Detail
-
setBackground
public static void setBackground(@NonNull android.view.View view, @Nullable android.graphics.drawable.Drawable drawable)Set background of a given view in an efficient way by detecting the Android SDK at runtime.- Parameters:
view- The view to set the background.drawable- The background drawable to be set.- See Also:
DynamicSdkUtils.is16()
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, boolean wrap, @NonNull android.graphics.ColorFilter colorFilter)Apply color filter and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.wrap-truetowrapthe drawable so that it may be used for tinting across the different API levels.colorFilter- The color filter to be applied on the drawable.- Returns:
- The drawable after applying the color filter.
- See Also:
Drawable.setColorFilter(ColorFilter),ColorFilter
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, boolean wrap, @ColorInt int color, @Nullable android.graphics.PorterDuff.Mode mode)Colorize and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.color- The color to colorize the drawable.wrap-truetowrapthe drawable so that it may be used for tinting across the different API levels.mode- The porter duff mode to be used.- Returns:
- The drawable after applying the color filter.
- See Also:
Drawable.setColorFilter(int, PorterDuff.Mode),PorterDuff.Mode
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, @ColorInt int color, @Nullable android.graphics.PorterDuff.Mode mode)Colorize and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.color- The color to colorize the drawable.mode- The porter duff mode to be used.- Returns:
- The drawable after applying the color filter.
- See Also:
Drawable.setColorFilter(int, PorterDuff.Mode),PorterDuff
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, boolean wrap, @ColorInt int color)Colorize and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.wrap-truetowrapthe drawable so that it may be used for tinting across the different API levels.color- The color to colorize the drawable.- Returns:
- The drawable after applying the color filter.
- See Also:
Drawable.setColorFilter(int, PorterDuff.Mode),PorterDuff.Mode.SRC_IN
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, @ColorInt int color)Colorize and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.color- The color to colorize the drawable.- Returns:
- The drawable after applying the color filter.
-
colorizeDrawable
@Nullable public static android.graphics.drawable.Drawable colorizeDrawable(@Nullable android.graphics.drawable.Drawable drawable, @NonNull android.graphics.ColorFilter colorFilter)Apply color filter and return the mutated drawable so that, all other references do not change.- Parameters:
drawable- The drawable to be colorized.colorFilter- The color filter to be applied on the drawable.- Returns:
- The drawable after applying the color filter.
- See Also:
Drawable.setColorFilter(ColorFilter),ColorFilter
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(int width, int height, @NonNull android.graphics.drawable.GradientDrawable drawable, @ColorInt int color)Get a gradient drawable according to the supplied drawable.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.drawable- The drawable drawable to create the gradient drawable.color- The color for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(int width, int height, @NonNull android.graphics.drawable.GradientDrawable drawable)Get a gradient drawable according to the supplied drawable.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.drawable- The drawable drawable to create the gradient drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(@NonNull android.graphics.drawable.GradientDrawable drawable, @ColorInt int color)Get a gradient drawable according to the supplied drawable.- Parameters:
drawable- The drawable drawable to create the gradient drawable.color- The color for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(@NonNull android.graphics.drawable.GradientDrawable drawable)Get a gradient drawable according to the supplied drawable.- Parameters:
drawable- The drawable drawable to create the gradient drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(int width, int height, float cornerRadius, @ColorInt int color)Get a gradient drawable according to the corner radius.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(int width, int height, float cornerRadius)Get a gradient drawable according to the corner radius.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(float cornerRadius, @ColorInt int color)Get a gradient drawable according to the corner radius.- Parameters:
cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static android.graphics.drawable.Drawable getCornerDrawable(float cornerRadius)
Get a gradient drawable according to the corner radius.- Parameters:
cornerRadius- The corner size in dip for the drawable.- Returns:
- The gradient drawable according to the supplied parameters.
-
-