第一行是在textview上显示文本的常规方法。
我怎么能像第二种方式一样展示?
任何帮助将不胜感激!谢谢!
答案 0 :(得分:0)
如果您正在寻找扩展其间空间以占据任何区域的文本,那就称为“对齐文本”。据我所知,它目前在Android中不受支持。不过,This link有很多变通办法,从自定义文字视图到使用网页视图。
修改强>
下面的方法似乎不再起作用了,或者至少当我插入它来尝试它时它没有。在这种情况下,我建议使用自定义视图。有关详细信息,请参阅链接。
可能最简单的方法是使用webview(从链接中挖走):
<!--create a webview in xml-->
<WebView
android:id="@+id/textContent"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
然后在您的活动中执行:
WebView view = (WebView) findViewById(R.id.textContent);
String text;
text = "<html><body><p align=\"justify\">";
text+= "123456789";
text+= "</p></body></html>";
view.loadData(text, "text/html", "utf-8");
答案 1 :(得分:-1)
String temp = "";
for(int i=0;i<10;i++){
temp=temp+i+" ";
}
textView1.setText(temp);