amulyakhare / TextDrawable

This light-weight library provides images with letter/text like the Gmail app. It extends the Drawable class thus can be used with existing/custom/network ImageView classes. Also included is a fluent interface for creating drawables and a customizable ColorGenerator.
MIT License
3.16k stars 611 forks source link

How to change background and text color same time? #60

Open Bekakk opened 7 years ago

Bekakk commented 7 years ago

Hi I'm using your Repo.I try to change background and text color same time.How I can do this? Here is my source

` public void setDrawableText(String text, int fontSize, int textColor,int backgroundColor) { drawable = TextDrawable.builder(). beginConfig(). fontSize(fontSize).toUpperCase(). useFont(typeface). endConfig(). buildRound(text, textColor);

    if (imageView != null && drawable != null)
        imageView.setImageDrawable(drawable);
}`
hrmck commented 4 years ago

you could try

public void setDrawableText(String text, int fontSize, int textColor,int backgroundColor) {
drawable = TextDrawable.builder()
.beginConfig()
.fontSize(fontSize).toUpperCase().useFont(typeface).textColor(textColor)
.endConfig()
.buildRound(text, backgroundColor);
if (imageView != null && drawable != null)
        imageView.setImageDrawable(drawable);
}

p.s. first time to use markdown, sorry if it looked terrible :/