简体   繁体   English

Android Java如何从右侧在新行中添加文本

[英]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: 我想在我的android应用示例中从右到左添加新行后向String添加文本:

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

so here the text start from the left, note that i am using a textView to display this String. 因此,这里的文本从左侧开始,请注意,我正在使用textView来显示此String。

Depending on what result you want use one of these in the TextView s Layout: 根据您想要的结果,在TextView的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. 我认为,如果您想在左侧和右侧保留一些行,则可以使用html标记,但是我不确定。

For other methods see How to make the text direction from right to left 有关其他方法,请参见如何使文本方向从右到左

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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