An library that tries to do cool stuff with colors.

The Android Arsenal - Animations -  - The Android Arsenal – Animations The Android Arsenal - Animations -  - The Android Arsenal – Animations

Add this to your gradle file:

    implementation 'com.simmorsal.recolor:recolor:1.0.1'


* setViewBackgroundColor()
* setCardViewColor()
* setTextViewColor()
* setImageButtonColorFilter()
* setImageViewColorFilter()
* setStatusBarColor()
* setNavigationBarColor()
* pulseStatusBar()
* pulseNavigationBar()
* stop()
* getColorList()
* setOnReColorFinish()

* setMenuIconColor()


  • setViewBackgroundColor(): changes the background color of any View you give it:
setViewBackground(view, startingColor, endingColor, duration);

// usage:
ReColor reColor = new ReColor(context);
reColor.setViewBackgroundColor(view, "FFFFFF", "#AA000000", 400);

// or like this:
new ReColor(context).setViewBackgroundColor(view, "#FFFFFF", "AA000000", 400);
  • setCardViewColor(): changes CardView color:
new ReColor(context).setCardViewColor(cardView, startingColor, endingColor, duration);

// usage:
new ReColor(context).setCardViewColor(cardView, "FFFFFF", "000000", 300);
  • setTextViewColor(): changes TextView color:
new ReColor(context).setTextViewColor(textView, startingColor, endingColor, duration);

// usage:
new ReColor(context).setTextViewColor(textView, "FFFFFF", "000000", 300);
  • setImageButtonColorFilter(): changes ImageButton‘s color filter:
new ReColor(context).setImageButtonColorFilter(imageButton, startingColor, endingColor, duration);

// usage:
new ReColor(context).setImageButtonColorFilter(imageButton, "FFFFFF", "000000", 300);
  • setImageViewColorFilter(): changes ImageView‘s color filter:
new ReColor(context).setImageViewColorFilter(imageView, startingColor, endingColor, duration);

// usage:
new ReColor(context).setImageViewColorFilter(imageView, "FFFFFF", "000000", 300);
  • setStatusBarColor(): changes Status Bar color. you can pass null as startingColor so it would be automatically retrieved from status bar itself:
new ReColor(context).setStatusBarColor(startingColor, endingColor, duration);

// usage:
new ReColor(context).setStatusBarColor(null, "000000", 300);

// or:

new ReColor(context).setStatusBarColor("FFFFFF", "000000", 300);
  • setNavigationBarColor(): changes Navigation Bar color. like the status bar, you can pass null as startingColor so it would be retrieved automatically:
new ReColor(context).setNavigationBarColor(startingColor, endingColor, duration);

// usage:
new ReColor(context).setNavigationBarColor(null, "000000", 300);

// or

new ReColor(context).setNavigationBarColor("FFFFFF", "000000", 300);
  • pulseStatusBar(): this method pulses the status bar color to the pulseColor, pulseCount times, each pulse taking pulseSpeed milliseconds:
new ReColor(context).pulseStatusBar(pulseColor, pulseSpeed, pulseCount);

new ReColor(context).pulseStatusBar("FFFFFF", 0, 4);
  • pulseNavigationBar(): just like pulseStatusBar(), but on Navigation Bar:
new ReColor(context).pulseNavigationBar(pulseColor, pulseSpeed, palseCount);

new ReColor(context).pulseNavigationBar("FFFFFF", 10, 5);
  • stop(): this method stops a reColoring on any of the above methods, and also returns the last color set by that particular ReColor object, in any of the above methods:
ReColor reColor = new ReColor(context);

// usage:
// Consider a LinearLayout's background being reColored
ReColor reColor = new ReColor(context)
    .setViewBackgroundColor(linearLayout, "FFFFFF", "000000", 2000);

// now you want to stop reColoring when a button is clicked
// (i also store the returned value)
    String lastColor = reColor.stop();

    // now i want to use the returned color to start reColoring to a new color
    reColor.setViewBackgroundColor(linearLayout, lastColor, "9C27B0", 500);
  • getColorList(): returns a List<String> of colors between startingColor and endingColor with a List length of listLength, so you can use it in your code:
new ReColor(context).getColorList(startingColor, endingColor, listLength);

// usage:
List<String> colorList = new ReColor(context)
    .getColorList("FFFFFF", "000000", 100);
  • setOnReColorFinish(): you can implement this on a ReColor object to get notified when reColoring finishes:
ReColor reColor = new ReColor(context);
reColor.setViewBackgroundColor(view, "FFFFFF", "000000", 1000);
reColor.setOnReColorFinish(new OnReColorFinish() {
                                    public void onFinish() {
                                        Log.i(TAG, "reColoring finished");

// or

new ReColor(context)
    .setViewBackgroundColor(view, "FFFFFF", "000000", 1000)
    .setOnReColorFinish(new OnReColorFinish() {
                                    public void onFinish() {
                                        Log.i(TAG, "reColoring finished");

Experimental methods:

  • setMenuIconColor(): changes MenuIcon of a MenuItem color:
    new ReColor(context).setMenuIconColor(menuItem, startingColor, endingColor, duration);

this method is experimental because while it’s reColoring a MenuIcon, the menu becomes unresponsive to touch. So the best way to use it is to give it a duration of 200 or less. and if you’re simulating pulsing, wait a bit before the next pulse begins. this is my implementation of pulsing:

MenuItem menuItem = navigationBarMenu.getItem(0);
final String startColor = "c60055", endColor = "40c4ff";

Handler handler = new Handler().post(new Runnable() {
             public void run() {

                 new ReColor().setMenuIconColor(menuItem, startColor, endColor, 100)
                         .setOnReColorFinish(new OnReColorFinish() {
                             public void onFinish() {

                                 new ReColor().setMenuIconColor(menuItem, endColor, startColor, 100)
                                         .setOnReColorFinish(new OnReColorFinish() {
                                             public void onFinish() {
                                                 handler.postDelayed(this, 1500);

Important notes

  • ONLY reColor one widget per object of ReColor class. In other words, DO NOT create one object of ReColor class and use it to reColor multiple widgets – at least at the same time.

  • you can pass color values in any of the following formats: "RRGGBB""AARRGGBB""#RRGGBB""#AARRGGBB"


My bitcoin address: 15NkTxJMdZinU2rUnENfjt62uHtxXCcpEU

The Android Arsenal - Animations -  - The Android Arsenal &#8211; Animations


Copyright 2018 SIMMORSAL

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Source link


Please enter your comment!
Please enter your name here