0

I am creating a view in which I have one ImageButton and one ImageView, and I want to change its color using image palette. I am getting the color from image but don't know how to set the image color (remember its ImageButton color, not background color).

Here is code that I have tried:

    Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {

        @Override
        public void onGenerated(Palette palette) {

            Palette.Swatch vibrantSwatch2 = palette.getLightVibrantSwatch();

            if (vibrantSwatch2 != null) {
                favourite.setColorFilter(vibrantSwatch2.getBodyTextColor());
                playlist.setColorFilter(vibrantSwatch2.getBodyTextColor());
            }

        }

    });
manfcas
  • 1,933
  • 7
  • 28
  • 47

1 Answers1

0

You can give tint using

favourite.setColorFilter(vibrantSwatch2.getBodyTextColor(),
                PorterDuff.Mode.SRC_ATOP);

Refer this.

Community
  • 1
  • 1
Kiran Benny Joseph
  • 6,755
  • 4
  • 38
  • 57