Reputation: 33846
I am generating a palette from a bitmap. I am making sure that I am getting a valid vibrant swatch and setting text color to that swatch's getTitleTextColor()
. The docs say:
Returns an appropriate color to use for any 'title' text which is displayed over this Swatch's color. This color is guaranteed to have sufficient contrast.
I after I get the text color, and set it I can hardly see the text.
Palette.from(bmp).generate(new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
Palette.Swatch swatch = palette.getVibrantSwatch();
if(swatch != null) {
Log.d(TAG, "Vibrant swatch found");
tvTitle.setTextColor(swatch.getTitleTextColor());
} else {
Log.d(TAG, "No color swatch found");
tvTitle.setTextColor(palette.getDarkVibrantColor(defaultColor));
}
}
});
Note: this is logging out "Vibrant swatch found"
See the text in the bottom left of the image? Me either....
Things worth noting:
This is what I am trying to accomplish
Upvotes: 1
Views: 1021
Reputation: 6393
According to this blog:
The different text colors roughly match up to the material design standard styles of the same name. The title text color will be more translucent as the text is larger and thus requires less color contrast. The body text color will be more opaque as text is smaller and thus requires more contrast from color.
So I think you should use swatch.getBodyTextColor()
instead. Also note that this title / body text color has sufficient contrast with the swatch's color (swatch.getRgb()
) which should be used as the background color for your text.
Upvotes: 2