Does anyone know if \u200b should be working on Android as a zero width space that functions as a line break if the TextView length is exceeded by the text of the TextView? It appears that only \u0020 is line breaking for me, but I’m not able to figure out how to have a zero width version of it. \u200b is what I expect should work, per the following link, but it only does the zero-width space and doesn’t break…and as stated, only \u0020 is line breaking.
http://www.cs.tut.fi/~jkorpela/chars/spaces.html
I’ve attached the view of an Activity I’m using for testing where U+ is being used in place of \u.
I’ve also tried using the fromHtml option to see if there is an Html option that works but haven’t had any luck with arial.
Here’s the test code I’m using
public class TextSpaceActivity extends Activity {
public static void start( Context ctx ) {
ctx.startActivity( new Intent( ctx, TextSpaceActivity.class ) );
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.text_space_activity );
setTitle( "TextSpaceActivity" );
setText( R.id.tsa_txvw_1, "abc\u0020123\u0020xyz\u0020987" );
setText( R.id.tsa_txvw_2, "abc\u200a123\u200axyz\u200a987" );
setText( R.id.tsa_txvw_3, "abc\u200b123\u200bxyz\u200b987" );
}
TextView txvw;
private void setText( int txvwResId, String txt ) {
txvw = (TextView)findViewById( txvwResId );
txvw.setText( txt );
}
}

I don’t believe the line-breaking algorithm understands the zero-width line-break, or soft hyphens, or the line- or paragraph-separator characters for that matter. Here’s the code from the Android source that decides if there can be a line break here (
android.text.StaticLayout, lines 358-366 in the source):where
isSpaceOrTabis defined just above (line 343) as:All the
CHAR_constants are plain character constants, so there’s nothing likeisspacegoing on. Lines 952-958 in the same file:Looking at your other comments, I see you’re trying to break Chinese correctly. You might not have to do anything special: as the
isIdeographiccall above hints, it tries to break between two ideographs without inserting spaces. Only theStaticLayoutbreaker does this:DynamicLayoutonly uses newline characters, so it will only break correctly on static text.I’m afraid from my research it looks like you’re screwed. My only suggestion for a work-around would be to use a
WebViewinstead of aTextView, and use the superior line-breaking capabilities of the system’s web browser instead of the limited implementationTextViewoffers.