Search code examples
androidtextview

Android - TextView textStyle is not changing


I want to switch TextView style from Bold to Normal based on data I got.

I'm doing it like this:

reserveCount.setText("Reservations " + reservationCount);
if(reservationCount<20){
  Log.i("reserveCount", "typeface: NORMAL");
  reserveCount.setTypeface(reserveCount.getTypeface(), Typeface.NORMAL);
} else {
  Log.i("reserveCount", "typeface: BOLD");
  reserveCount.setTypeface(reserveCount.getTypeface(), Typeface.BOLD);
}

But style is not changing at all (it stays bold all the time).


Solution

  • try to call reserveCount.invalidate() or reserveCount.requestLayout() at the end for forcing redraw View