如何在 Android 中对齐 TextView 的文本 [英] How to justify text of TextView in Android
本文介绍了如何在 Android 中对齐 TextView 的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
希望你一切顺利
我想在 TextView
中对齐我的文本,
I want to Justify my Text in TextView
,
有没有办法做到这一点?
Is there any way to do that?
提前致谢
推荐答案
XML 布局:声明 WebView 而不是 TextView
XML Layout: declare WebView instead of TextView
<WebView
android:id="@+id/textContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Java 代码:将文本数据设置为 WebView
Java code: set text data to WebView
WebView view = (WebView) findViewById(R.id.textContent);
String text;
text = "<html><body><p align=\"justify\">";
text+= "This is the text will be justified when displayed!!!";
text+= "</p></body></html>";
view.loadData(text, "text/html", "utf-8");
这可能会解决您的问题.
This may Solve your problem.
这篇关于如何在 Android 中对齐 TextView 的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文