简体   繁体   中英

android java how to append a text in new line from the right side

I want to append a text to String after adding new line starting from right to left in my android app example:

String g= "مرحبا";
g.append("\n اهلا");

so here the text start from the left, note that i am using a textView to display this String.

Depending on what result you want use one of these in the TextView s Layout:

android:textDirection="anyRtl"

(this sets text layout to Right-to-left)

android:gravity="right"

(this aligns the text on the right)

I think if you want to have some lines left and some right you could use html markup, but I'm not sure about that.

For other methods see How to make the text direction from right to left

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM