Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Span or Non-Breaking Space Causing line break and text duplication (4.0 ICS)
    text
    copied!<p>I'm using several text views with heavy use of spans.</p> <p><strong>The Problem:</strong> Sometimes in my app (specifically on Ice Cream Sandwich) I will see a line break that isn't in the text string, along with text duplication. See the image below for an example. Notice how the third sentence begins, then there is a line break, then the text is duplicated and the sentence finishes.</p> <p><img src="https://i.stack.imgur.com/UcHoS.png" alt="enter image description here"></p> <p><strong>Code:</strong></p> <pre><code>tv = (TextView) inflater.inflate(R.layout.fragment_reader_list_item, parent, false); SpannableStringBuilder ssb = ssbList.get(position); tv.setText(ssb, BufferType.SPANNABLE); </code></pre> <p>When I debug into the code, the variable 'ssb' properly only contains the text ..."3 not domineering over those in your charge, but being examples to the flock. 4 And when the chief"...</p> <p><strong>Some specifics I've noticed from playing around with it for a few hours:</strong> The conditions that cause the bug seem to have something to with with the overall width of the rendered text. For instance, with the text pictured above, if I turn off bold span on the numbers, the pictured text will show properly, however if I leave the bold span, andturn off the color change span on the number (which doesn't change the width at all), the issue persists.</p> <p>It's also worth noting that after each number I'm using a non-breaking space. If I swap the non-breaking space with a breaking space, I don't see the issue anymore, but that's more or less probably because the rendered string changes. This issue may not have anything to do with spans, but it seems like too big of a bug to pass with just any old text.</p> <p>Any help is greatly appreciated!</p> <p><strong>EDIT:</strong> This bug seems strongly linked to the use of the Bold span. Taking it off of the numbers fixes the problem. That's what I've currently resorted to as a work-around. It'd be nice if there was a better option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload