Rainbow
An easy way to apply gradations and tinting for Android.
Download
Gradle
Add a dependency code to your module's build.gradle
file.
Usage
We can apply gradations and tinting to any views easily using Rainbow
class.
Palette
Palette lambda expression collects colors for creating gradation.
We can collect colors using contextColor
and color
functions.
contextColor
gets a resource color from your colors.xml
file, and color
gets a ColorInt color.
They should be used with +
operator in the palette lambda expression.
Here is a kotlin-extesion way to apply gradations using View.rainbow()
method to views.
Background, Foreground
We can apply gradations composed with palette colors to the view's background or foreground.
The forground()
method can be applied to your CardView
or something others.
And we can control the gradient orientation and corner radius.
We can use 8 kinds of orientation which RainbowOrientation
.
Tinting
We can change some kinds of view's tint colors which can be applied tint.
Here are views can be applied tint: TextView(drawable), ImageView, CompoundButton, TintableBackgroundView.
Drawable
We can get a GradientDrawable
using getDrawable
method.
RainbowView
RainbowView is a gradient view for implementing gradations.
Add following XML namespace inside your XML layout file.

RainbowView in xml layout
Tha rainbowView_colors
attributes gets color list from the color-array from your colors.xml
.
BinaryRainbowView
BinaryRainbowView is a gradient view for implementing a simple view with gradations.
Shuffle
RainbowView
and BinaryRainbowView
provides shuffling the palette colors using shuffleColors()
method. The gradation colors placement will be changed randomly.
Usage in Java
Here are some usages for Java developers.