【发布时间】:2018-07-19 17:46:18
【问题描述】:
我已尝试使用以下代码在文本视图中的两行之间绘制一条水平线:
String line1="<br>This is line 1</br>";
String line2=" This is line 2";
String htmlCode =line1 +"<hr>"+line2;
myTextView.setText(Html.fromHtml(htmlCode));
我也试过了:
String line1="<br>This is line 1</br>";
String line2=" This is line 2";
String htmlCode =line1 +"<span style='border-bottom:1px solid'</span>"+line2;
我正在尝试将此代码存储到数据库中,并进一步获取文本并显示在视图中。
String htmlCode= GetTextFromDB();
myTextView.setText(Html.fromHtml(htmlCode));
在所有其他标记(如 br 和 &nbsp; 运行良好)的情况下,带边框的水平线部分/跨度不起作用
【问题讨论】:
-
你想给文本加下划线还是放行分隔符?
-
阅读stackoverflow.com/questions/10754265/…的解决方案。这和你需要的一样。
-
我有一些文本存储在数据库中。我只想拿起那些文本并在视图中写下。因此,在将它们存储到数据库之前,我尝试添加 html 标记。@prashant17