DrawableColorChange

Additional

Language
Java
Version
1.2 (Sep 19, 2016)
Created
Sep 18, 2016
Updated
Dec 4, 2017
Owner
Mathiazhagan (mathiazhagan01)
Contributor
Mathiazhagan (mathiazhagan01)
1
Activity
Badge
Generate
Download
Source code

Advertisement

DrawableColorChange

Android Library to dynamically change color of drawable.

If you like the library, please rate us on codix.io!

Gradle

Step 1. Add the JitPack repository to your build file

Add it in your root build.gradle at the end of repositories:

     allprojects {
  repositories {
   ...
   maven { url "https://jitpack.io" }
    }
 }

Step 2. Add the dependency

     dependencies {
         compile 'com.github.mathiazhagan01:DrawableColorChange:1.4'
 }

Maven

Step 1. Add the JitPack repository to your build file

     <repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
 </repositories>

Step 2. Add the dependency

   <dependency>
       <groupId>com.github.mathiazhagan01</groupId>
       <artifactId>DrawableColorChange</artifactId>
       <version>1.4</version>
   </dependency>

Before changing color

After changing color

Example 1

   DrawableColorChange drawableColorChange = new DrawableColorChange(this); 
  
   drawableColorChange.setDrawable(R.drawable.icon);
   drawableColorChange.setColorResId(R.color.colorAccent);
   Drawable drawable = drawableColorChange.getColorChangedDrawable();
   ImageView imageView = (ImageView) findViewById(R.id.image);
   imageView.setImageDrawable(drawable);

Example 2

   imageView.setImageDrawable(drawableColorChange.changeColorById(R.drawable.icon, R.color.colorAccent));

Example 3

   drawableColorChange.setDrawable(R.drawable.icon);
 drawableColorChange.setColorResId(R.color.colorAccent);
 Bitmap bitmap = drawableColorChange.getColorChangedBitmap();
 imageView.setImageBitmap(bitmap);

LICENSE

DrawableColorChange library for Android
Copyright (c) 2017 Mathiazhagan Dinesh (http://github.com/mathiazhagan01).

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

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
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.