【问题标题】:Character for inserting line break instead of creating paragraph in Android用于插入换行符而不是在 Android 中创建段落的字符
【发布时间】:2019-11-18 18:00:34
【问题描述】:

是否有插入line break 而不在TextView 中创建新paragraph 的字符?

真的,我有一个双向文本,想在TextView 中显示它。现在我必须在 LTRRTL 部分文本之间添加换行符,而无需在每次换行后更改文本方向。

很明显,使用\n 会创建新段落,因此每个新段落的方向将由其内容决定,并且不会与整个文本的方向一起排版。

LibreOffice Writer 中,我们可以使用 SHIFT+ENTER 来添加换行符而不是新段落。这在Android 中可行吗?注意我不想使用HTML<br/> 标签。

【问题讨论】:

  • 你试过用android:layoutDirection="ltr" 设置TextView的布局方向吗?

标签: android text textview line-breaks


【解决方案1】:

你可以使用 \n 在你想换行的地方,如下所示

textView.setText("Hello \n World")

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Hello \n World"
                android:textSize="45dp"/>

【讨论】:

  • 我提到“\n”创建新段落。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-27
  • 2013-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多