Last week I open sourced an Android library called ColorArt, which is a port of the popular OS X library written by the guys over at Panic. It allows you to use a source image to create a themed image/text display, very similar to the effect which is done in iTunes 11.
Using the Library
ColorArt is pretty easy to use, and can add a cool effect to any app. In order to add it to your project, add the dependency to your build.gradle
file:
1
|
|
The next thing you need is to take a Bitmap that you want to use, and pass it to a ColorArt object:
1 2 |
|
After that, it’s as simple as calling some getter methods in order to get the colors that make up the image:
1 2 3 4 |
|
Voilà! Now you can make cool themed image/text display using Bitmaps as part of your application.
Bonus: FadingImageView
I also added a class that extends ImageView, which will allow you to add a subtle gradient from the image, to the background color, similar to what you see in the iTunes display. It’s also extremely easy to use:
- Replace the ImageView that you are presently using with a
FadingImageView
. - Call
1
|
|
to set the background color to fade to, and which side gets the gradient.
That’s it!
You can also toggle that gradient with a call to mImageView.setFadeEnabled(true/false);
.
Are you using this library in your app? Please let me know so I can add a link to it on the GitHub project page! Also, feel free to send pull requests!