1

I have a textview that will contain various numbers between 1 and 6, each number represented once on each line e.g

123456
213456
214356
......

I want to be able to draw a blue line to followa single numerical value as it moves down the list. So if we choose the number 2, then the line would connect each successive number 2 in the text view.

How can this be done? Can you have a some kind of graphics view sitting on top of the textView and supply coordinates to it to draw a line?

Allan Macmillan
  • 1,481
  • 3
  • 18
  • 30
  • Just a thought, would it satisfy your needs if that value were to be displayed in a different colour to all the rest? If so a SpannableString would provide a much easier mechanism to implement. – NickT Oct 14 '13 at 10:09
  • No, i need a graphical line running down the textView – Allan Macmillan Oct 14 '13 at 10:09
  • what you need is a border around the textview that only has a bottom line. Take a look [here](http://stackoverflow.com/questions/1598119/is-there-an-easy-way-to-add-a-border-to-the-top-and-bottom-of-an-android-view) – Lefteris Oct 14 '13 at 10:14
  • Its not a border i need but a line running through the textView that goes through each number 2. – Allan Macmillan Oct 14 '13 at 10:19

1 Answers1

1

I would create a subclass of TextView. Inside this subclass overwrite onDraw(Canvas). Inside onDraw(), call super.onDraw() at first and then use getLineBounds and getPaint().measureText(...) to find out the center positions of the numbers you want to connect with a line. Finally just draw the line along these positions. May still be a bit complicated but not impossible.

user2808624
  • 2,502
  • 14
  • 28