Use a View with fixed height –
android:layout_width="fill_parent" android:layout_height="2dip" android:background="#FF00FF00" />
or, in code –
View ruler = new View(myContext); ruler.setBackgroundColor(0xFF00FF00); theParent.addView(ruler, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 2));
Source – Romain Guy
Good example. I used the code one creating dynamically.
can u show the code..Since i am getting force close for the above code…
copy and paste this code
I would love to use the code version but it give me a error on “theParent”
That is because you have to declare “theParent”, or change it to the parent you want to add the rule to. For example, the RelativeLayout, or whatever layout you are using.
// TheDDestroyer12
Thanks for that.
I put the xml between a couple of tablelayouts inside of a framelayout. Worked beautifully.
Nice tip.
I’ve been looking for this so long.
Nice little tip. I will certainly use this in my future apps. Thanks for sharing.
thanu so mch its very helpful….
Excellent post. Brevity is the soul of whit. Thank you for showing the non-XML method.
Thanks!
So simple 😉
Thank you so much!!
just wanted to say that you have the say wordpress layout as me. What plugin are you using for the capcha? Thanks.
how to set width of the line?
Thank you for this, works wonderfully