0

I am able to easily place a horizontal line programmatically.

View view2 = new View(this);
view2.setBackgroundColor(0xFFC2BEBF);
relativelayout.addView(view2, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 2));

I now cannot find a solution to make a similar line except make it vertical. Again, this needs to be done all programmaticallly. I found a solution here but the code they provided did not work for me. The code supplied in the link can be found below.

view v = new View(this);
v.setLayoutParams(2,new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT));

It is so simple to make the horizontal line. How can I get my vertical line to work?

Community
  • 1
  • 1
Matt
  • 3,882
  • 14
  • 46
  • 89
  • 1
    Have you tried interchanging `LayoutParams`'s arguments? Like this: `relativelayout.addView(view2, new ViewGroup.LayoutParams(2, ViewGroup.LayoutParams.MATCH_PARENT));` – M-Wajeeh Nov 26 '13 at 17:56

1 Answers1

2

Try This:

relativelayout.addView(view2, new ViewGroup.LayoutParams(2,ViewGroup.LayoutParams.MATCH_PARENT));
  • I could have sworn I tried this exact code and it didn't work before I posted my opening post. Anyways, this worked exactly like it should have! Thank you! – Matt Nov 26 '13 at 18:16