When setting the text in code, invalidate() isn't called (just requestLayout()), which doesn't redraw the text. I would suggest calling both invalidate() and requestLayout(), as explained here: Why is requestLayout being called directly after invalidate?
Also, if I set a text with xml attributes (kswTextOn), the text will be centered. Now, if I update the text in code, the text will keep the position of the initial text and won't look great.