I decided to split the text block by implementing ReplacementSpan to render the text in one block. Here is the code:
public class NonbreakingSpan extends ReplacementSpan { @Override public void draw( Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) { canvas.drawText(text, start, end, x, y, paint); } @Override public int getSize( Paint paint, CharSequence text, int start, int end, FontMetricsInt fm) { return Math.round(paint.measureText(text, start, end)); } }
source share