0

how do I draw a horizontal line in a relativelayout without create a class that extends View and without XML? I need to draw a simply line in a RelativeLayout in a given point of Cartesian plane

Roran
  • 423
  • 1
  • 4
  • 21

1 Answers1

0

You can try out this:

View line = new View(this);
line.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1));
line.setBackgroundColor(Color.rgb(51, 51, 51));
layout.addView(line);

There are other ways too through paint.

Rishabh Srivastava
  • 3,643
  • 2
  • 28
  • 57
  • I added line.setY(value) and replaced FILL_PARENT with MATCH_PARENT,now it works,thank you – Roran Nov 12 '13 at 10:41