ChatKit icon indicating copy to clipboard operation
ChatKit copied to clipboard

when I'm setting the bubble color programmatically it lose its shape

Open dekanako opened this issue 5 years ago • 3 comments

image

dekanako avatar Apr 16 '20 12:04 dekanako

Hi! Do you use Styling via attributes?

bevzaanton avatar Apr 23 '20 11:04 bevzaanton

mBubble.setBackgroundColor(mContext.getResources().getColor(R.color.mRed));

no I'm using this line, I'm using it when a message is not delivered to the user

dekanako avatar Apr 23 '20 11:04 dekanako

Unfortunately, you can't just set bg color without change the shape of a bubble. MessageListStyle use this method to set bg color of a bubble:

 private Drawable getMessageSelector(@ColorInt int normalColor, @ColorInt int selectedColor,
                                        @ColorInt int pressedColor, @DrawableRes int shape) {

        Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate();
        DrawableCompat.setTintList(
                drawable,
                new ColorStateList(
                        new int[][]{
                                new int[]{android.R.attr.state_selected},
                                new int[]{android.R.attr.state_pressed},
                                new int[]{-android.R.attr.state_pressed, -android.R.attr.state_selected}
                        },
                        new int[]{selectedColor, pressedColor, normalColor}
                ));
        return drawable;
    }

You could use something similar to it.

bevzaanton avatar Apr 23 '20 12:04 bevzaanton