Allan Macmillan
Allan Macmillan

Reputation: 1491

Android Drawing/Graphics

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?

Upvotes: 1

Views: 92

Answers (1)

user2808624
user2808624

Reputation: 2530

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.

Upvotes: 1

Related Questions