user10238140
user10238140

Reputation:

Change TextStyle Programmatically

@Override
protected void onBindViewHolder(@NonNull final Chat.MessagesViewHolder holder, final int position, @NonNull final MessagesHelper model) {
       holder.mDisplayText.setBackgroundColor(BackgoundColorSent);
}

I can do that for textColor and size but there is no method for textStyle. I'm using a firebaseRecyclerAdapter and wish to change the style of the item of recyclerView programmatically as the user pleases.

Upvotes: 2

Views: 119

Answers (2)

Ali Ahmed
Ali Ahmed

Reputation: 2178

You can use setTypeface for applying styles to your text

textView.setTypeface(Typeface.BOLD_ITALIC);

Other Typefaces you can use are:

  1. Typeface.BOLD
  2. Typeface.NORMAL
  3. Typeface.SANS_SERIF
  4. Typeface.MONOSPACE
  5. Typeface.ITALIC

Upvotes: 1

Boris Van Leuven
Boris Van Leuven

Reputation: 21

It's better to change the texstyle with the command in the xml file "textStyle()"

You need to change it in your layout from your itemview.

I hope I could help you.

enter image description here

Upvotes: 0

Related Questions