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?

4

1 回答 1

1

我会创建一个 TextView 的子类。在这个子类中覆盖 onDraw(Canvas)。在 onDraw() 内部,首先调用 super.onDraw() ,然后使用 getLineBounds 和 getPaint().measureText(...) 找出要连接线的数字的中心位置。最后沿着这些位置画线。可能仍然有点复杂,但并非不可能。

于 2013-10-14T18:19:50.410 回答