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 622 forks source link

Custom Color not assuming #70

Open FilipeOS opened 6 years ago

FilipeOS commented 6 years ago

Hi there,

I have tried to place a custom color coming from color.xml but it's not assuming, it's showing a random color, not the one I try to use, even on MATERIAL or DEFAULT

`String firstLetter = String.valueOf(calls.getName().charAt(0));

    ColorGenerator generator = ColorGenerator.MATERIAL;
    int color = generator.getColor(R.color.amber_400);

    TextDrawable drawable = TextDrawable.builder()
            .beginConfig()
            .fontSize(50)
            .bold()
            .toUpperCase()
            .endConfig()
            .buildRound(firstLetter, color);`

Can someone help?

pasdam commented 6 years ago

In an Activity or a Fragment you can do this:

int color = getResources().getColor(R.color.amber_400);

TextDrawable drawable = TextDrawable.builder()
            .beginConfig()
            .fontSize(50)
            .bold()
            .toUpperCase()
            .endConfig()
            .buildRound(firstLetter, color);

Source.