1

I have tried the following code to draw a horizontal line between two lines in text view:

String line1="<br>This is line 1</br>";
String line2="&nbsp;This is line 2";
String htmlCode =line1 +"<hr>"+line2;
myTextView.setText(Html.fromHtml(htmlCode));

I also tried:

    String line1="<br>This is line 1</br>";
    String line2="&nbsp;This is line 2";
    String htmlCode =line1 +"<span style='border-bottom:1px solid'</span>"+line2;

I am trying to store this code into database and further fetch the text and display in view.

String htmlCode= GetTextFromDB();
myTextView.setText(Html.fromHtml(htmlCode));

the horizontal line part/span with border is not working where all other markups like br and &nbsp; are working well

Sajjad raihan
  • 23
  • 1
  • 6
  • You want to underline text or put a line separator? – prashant17 Jul 19 '18 at 08:52
  • Read solution of https://stackoverflow.com/questions/10754265/androiddraw-line-on-a-textview/10770670#10770670. This is same as you need. – Pankaj Kumar Jul 19 '18 at 08:58
  • I have some texts stored in database. I just want to pick up those texts and write on view. So before storing them into database I am trying to add html markups.@prashant17 – Sajjad raihan Jul 19 '18 at 09:20

1 Answers1

0
View viewHorizontleLine = new View(this); v.setLayoutParams(new LinearLayout.LayoutParams(
        LayoutParams.MATCH_PARENT,      
        5 )); viewHorizontleLine.setBackgroundColor(Color.parseColor("#A1A1A1"));

LinearLay.addView(viewHorizontleLine);

Try this one make a horizontal line programetically hope this may help you

InsaneCat
  • 2,115
  • 5
  • 21
  • 40