Skip to content

ColorUtils

Shanti Ranjan Das edited this page Jan 24, 2020 · 2 revisions
  • getAttributeColor(context: Context, @AttrRes attr: Int): Int
    This method is responsible for getting int color from attributes, return white if color is null.

  • getTitleTextColor(@ColorInt color: Int): Int
    Method to get Title text color for an app,Just pass the color and it will calculate new color according to provided color.

  • getBodyTextColor(@ColorInt color: Int): Int
    Method to get body text color for an app,Just pass the color and it will calculate new color according to provided color.

  • getDarkerColor(@ColorInt color: Int, @FloatRange(from = 0.0,to = 1.0) transparency: Float): Int
    Method to get Darker color from provided color

  • setColorAlpha(@ColorInt color: Int, @FloatRange(from = 0.0, to = 1.0) alpha: Float): Int
    Method to get transparency from provided color

  • getColorStateList(@ColorInt color: Int): ColorStateList
    Method to get color state list .i.e., weather it is pressed_state or focuses_state

  • getCheckedColorStateList(@ColorInt unchecked: Int, @ColorInt checked: Int): ColorStateList
    Method to get Checked Color State List

  • isValidColor(string: String): Boolean
    Check weather it is a valid color string code or not, like "#000000". Returns true if valid else false.

  • intToARGBString(@ColorInt color: Int): String Convert a color to an Alpha Red Green Blue string. Returns the color as string, or null if color is null.

  • argbStringToInt(color: String)
    Parse alpha Reg green blue color String to int color. Like #FFFFFF

  • convertColor(color: Int): String
    Parse Reg green blue color String to int color. Like #FFFFFF

  • changeDrawableColor(@DrawableRes drawableId: Int, color: Int)
    Change the color of the provided drawable.

  • changeDrawableOutlineColor(@DrawableRes drawableId: Int, color: Int, strokeWidth: Int = 3)
    Change drawable outline color.

Clone this wiki locally