MasayukiSuda / BubbleLayout

Bubble View for Android.
973 stars 135 forks source link

setBubbleColor always gray #11

Closed Yisas closed 7 years ago

Yisas commented 7 years ago

The issue could be specific to when populating through an adapter. Inside the poplateView I have:

protected void populateView(View v, ChatMessage model, int position) {
 BubbleLayout bubble;
 bubble = (BubbleLayout) v.findViewById(R.id.bubble);

 if (model.getMessageUser() != null && messageAuthor.equals(currentUsername)) {
            RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) bubble.getLayoutParams();
            params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

            bubble.setArrowDirection(ArrowDirection.RIGHT);
            bubble.setBubbleColor(R.color.colorPrimary);
        }

The arrow direction works well, but the bubbles always looks dark gray regardless of the value of R.color.colorPrimary in the values resource folder. Setting the color of the bubble in the xml layout works (displays the right color) for the bubbles that don't meet the condition in the above statement.

MasayukiSuda commented 7 years ago
bubble.setBubbleColor(ContextCompat.getColor(context, R.color.colorPrimary));

I think that it will be successful.