Palette.Swatch - 充满活力的 getTitleTextColor 一点也不充满活力

Palette.Swatch - vibrant getTitleTextColor is not at all vibrant

我正在从位图中生成调色板。我正在确保我得到一个有效的充满活力的样本并将文本颜色设置为该样本的 getTitleTextColor()。文档说:

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.

我拿到文字颜色,设置好之后,我几乎看不到文字了。

代码:

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));
                }
            }
});

注意:这是注销"Vibrant swatch found"

结果:

看到图片左下角的文字了吗?我也是....

注意事项:

编辑:

This is what I am trying to accomplish

根据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.

所以我认为您应该改用 swatch.getBodyTextColor()。另请注意,此标题/body 文本颜色与样本颜色 (swatch.getRgb()) 具有足够的对比,应该用作文本的背景颜色。