关于文本两端对齐的问题,可以参考如下:
To justify text in android I used WebView
setContentView(R.layout.main);
WebView view = new WebView(this);
view.setVerticalScrollBarEnabl ed(false);
((LinearLayout)findViewById(R. id.inset_web_view)).addView(vi ew);
view.loadData(getString(R.stri ng.hello), "text/html", "utf-8");
and html.
<string name="hello">
<![CDATA[
<html>
<head></head>
<body style="text-align:justify;colo r:gray;background-color:black; ">
Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nunc pellentesque, urna
nec hendrerit pellentesque, risus massa
</body>
</html>
]]>
</string>
I can't yet upload images to prove it but "it works for me".
主要思路:使用WebView来加载,用css来实现两端对齐。
注意:webview要设置成透明的,还有加载时使用
myWebView. loadDataWithBaseURL("", getString(R.string.desc), "text/html", "utf-8",""); 这个方法
// myWebView.loadData(getString( R.string.desc), "text/html", "utf-8"); // 这个方法遇到一些字符中会乱码
Thanks
版权声明:本文为WOSHICAIXIANFENG原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。