0

I have custom views and when I place them on my Activity (or Fragment) I would like to connect them with a simple line (or if you have another idea I will listen to it).

So here is an example:

enter image description here

As you can see, I have 2 views and when I place the second below my first one, I would like to connect the two views with a simple line. (It would be cool to draw a curved line if it's not perfectly below the other component but I am cool with just a straight line.)

So how can I do this? It sounds simple but I don't know how to start it.

Daniel
  • 10,641
  • 12
  • 47
  • 85
  • get the position of the two views http://stackoverflow.com/questions/2224844/how-to-get-the-absolute-coordinates-of-a-view from their position you can use canvas.drawline() function on your ondraw() function of your custom view – Illegal Argument Sep 02 '16 at 08:12
  • @IllegalArgument so I have to make another custom view what will draw the line between them? – Gábor Vecsei Sep 02 '16 at 10:41

1 Answers1

0

Get the bottom line of the first block. Using the width of the block and the co ordinates of the corner find the mid position. Do the same with the second block for the top line of the second block. then use canvas.drawLine() in your onDraw() method.

Sahana Prabhakar
  • 581
  • 1
  • 8
  • 21