如何突破线路在机器人EditText
字母,所以它成了这个样子:歇线
Hello how to br
eak by letters
instead of word
s
取而代之的是:
Hello how to
break by
letters
instead of
words
CSS中的模拟是word-break: break-all
PS当然,文本正在动态变化。
如何突破线路在机器人EditText
字母,所以它成了这个样子:歇线
Hello how to br
eak by letters
instead of word
s
取而代之的是:
Hello how to
break by
letters
instead of
words
CSS中的模拟是word-break: break-all
PS当然,文本正在动态变化。
试试这个 // tmpString - 要显示的字串
// 15 - 没有。信你要改变按照您的要求
int index = 0;
StringBuffer finalString = new StringBuffer();
while (index < tmpString.length()) {
finalString.append(tmpString.substring(index, Math.min(index + 15,tmpString.length()))+"\n");
index += 15;
}
editText.setText(finalString);
它所称的“对齐文本”或“文本对齐”,但在Android
它不支持,至少到现在为止。
有一种解决方案,如果你想实施。它使用WebView
并加载HTML
格式的文本并将body
样式设置为justify
。如果你真的需要'文本理由',这只是一个解决方案。
您可以使用自动调整编辑文本具有以下属性:
android:inputType="textMultiLine"
android:layout_height="wrap_content"
完整的EditText布局实例:
<EditText
android:layout_width="match_parent"
android:inputType="textMultiLine"
android:layout_height="wrap_content"
android:hint="Enter Text"
android:textColorHint="@color/primary_color"
android:ems="10"
android:imeOptions="actionDone"
android:id="@+id/message_input"
android:layout_gravity="center_horizontal"/>