希望你一切都好。
我想在TextView
中对齐我的文本,有没有什么办法可以做到这一点?
谢谢您的帮助。
XML布局:声明WebView而不是TextView
<WebView
android:id="@+id/textContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Java代码:将文本数据设置为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");
我使用这个项目来调整文本。它在我的项目中运行良好。JustifiedTextView
XML代码
<com.codesgood.views.JustifiedTextView
android:padding="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/card_use_hint"/>
结果