how to set border top or bottom line on Label?
I want to show a horizontal line, it seems like <hr> on html.
<html>
<body>
<div>.... #######</div>
<hr />
<div>.... #######</div>
</body>
</html>
app.js
var label = Ti.UI.createLabel({borderWidth:1}); //this display four sides
// how to just show border top?
Can anyone help with this?
Thanks.
5 Answers
-
I solve with this,
var separator = Ti.UI.createView({ width:'100%', height:1, backgroundColor:'white', bottom:0, });
-
you can't.
can you eventually add a 1px high View Object with a backgroundColor to your label? - didn't test it tho… -
Have you tried to use a background image? labelname.backgroundImage
-
Becca
You should not add a view to a label, as another poster has suggested. Certainly in android, this is not supported.
To achieve your goal, you need to create a 1px-high (or however thick you would like your line) view and position it directly above your label.
If you need to be able to move the label and the line around and for them to stay together, then either set the container view (or window) with a vertical layout and add the label to the container directly after the line. Alternatively, add both the line and the label to a view, and move that around instead.
Hope this helps
-
I solve this by making an hr constructor like this:
hr = () -> _view = Titanium.UI.createView({ width: "100%" height: 1 borderWidth: 1 borderColor: "blue" }) return _view
then I add it anywhere I need one
*note that I am using coffee script