小智 6
XML 布局:声明 WebView 而不是 TextView
<WebView
android:id="@+id/textContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
Run Code Online (Sandbox Code Playgroud)
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");
Run Code Online (Sandbox Code Playgroud)
这可能会解决您的问题。
| 归档时间: |
|
| 查看次数: |
15497 次 |
| 最近记录: |