I'm experiencing inconsistent text wrapping behavior between an Android emulator and a Google Pixel 8 device when displaying Urdu/Arabic text in a TextView
Issue:
On the emulator, some Urdu/Arabic words break into two lines even though maxLines="1" is set.
On the Pixel 8, the same words stay on one line, even when they are long.
The text direction should dynamically adjust based on the selected language.
Code I'm Using:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textDirection="locale"
android:layoutDirection="locale"
android:maxLines="1"
android:ellipsize="end"
android:breakStrategy="simple"
android:fontFamily="sans-serif"
/>
What I've Tried:
Using maxLines="1" – Still wraps on the emulator.
Adding ellipsize="end" – Doesn't always prevent breaking.
Forcing android:breakStrategy="simple" – No visible difference.
Checking hidden characters (\u200B, \u00A0, \u200F) – Didn't find any.
Testing different fonts – I can't change fonts, so I need a solution that works with the default system fon
t.
Questions:
Why is text breaking differently on the emulator vs. the Pixel 8?
How can I force consistent single-line behavior across all devices for Urdu/Arabic text?
Is there a better approach to handling RTL text wrapping dynamically without hardcoding text direction?
Any insights or workarounds would be greatly appreciated. Thanks!