Android开发:文本实现两端对齐
2012-07-23 09:53
239 查看
关于文本两端对齐的问题,可以参考如下:
To justify text in android I used WebView
and html.
I can't yet upload images to prove it but "it works for me".
来源:http://stackoverflow.com/questions/1292575/android-textview-justify-text
主要思路:使用WebView来加载,用css来实现两端对齐。
注意:webview要设置成透明的,还有加载时使用
myWebView.loadDataWithBaseURL("", getString(R.string.desc), "text/html", "utf-8",""); 这个方法
// myWebView.loadData(getString(R.string.desc), "text/html", "utf-8"); // 这个方法遇到一些字符中会乱码
Thanks
To justify text in android I used WebView
setContentView(R.layout.main); WebView view = new WebView(this); view.setVerticalScrollBarEnabled(false); ((LinearLayout)findViewById(R.id.inset_web_view)).addView(view); view.loadData(getString(R.string.hello), "text/html", "utf-8");
and html.
<string name="hello"> <![CDATA[ <html> <head></head> <body style="text-align:justify;color: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".
来源:http://stackoverflow.com/questions/1292575/android-textview-justify-text
主要思路:使用WebView来加载,用css来实现两端对齐。
注意:webview要设置成透明的,还有加载时使用
myWebView.loadDataWithBaseURL("", getString(R.string.desc), "text/html", "utf-8",""); 这个方法
// myWebView.loadData(getString(R.string.desc), "text/html", "utf-8"); // 这个方法遇到一些字符中会乱码
Thanks
相关文章推荐
- Android开发:文本实现两端对齐
- Android 自定义Textview实现文字两端对齐功能和长按自由选择文字弹出自定义ActionMenu功能(二)自定义ActionMenu
- android 开发:使得TextView文本左右两边都对齐--解决中英文对齐问题。
- Android开发之文本内容自动朗读功能实现方法
- Android开发中TextView文本过长滚动显示实现方法分析
- Android 自定义Textview实现文字两端对齐功能和长按自由选择文字弹出自定义ActionMenu功能(一)
- Android 实现两端对齐的文字排版
- text-align:justify实现文本两端对齐 兼容IE
- Android中用webView来解决文字排版实现两端分散对齐的方式
- text-algin:justify实现文本两端对齐方法小结
- [Android][实现类似表单上的文字,两端对齐,文字间距相等]
- Android开发之文本中缩略图点击弹出大图效果实现
- text-align:justify实现文本两端对齐布局,兼容IE
- [Android]TextView实现分散对齐(两端对齐)
- android LinearLayout 实现两端对齐
- Android实现TextView两端对齐的方法
- Android]TextView实现分散对齐(两端对齐)
- Android TextView两端对齐、文本两端对齐
- android开发 自定义View实现TextView文本间距
- css实现div内一段文本的两端对齐