how to give border and border-radius to stacklayout in nativescript
Asked Answered
R

3

7

I'm new to nativescript.I don't know how to give border and border-radius to stacklayout.

Below I have posted what I tried so far:

component.html:

 <StackLayout class ="stackBorder" orientation="horizontal">
    <Label text="Label 1" width="50" height="50" > </Label>
    <Label text="Label 2" width="50" height="50" > </Label>
    <Label text="Label 3" width="50" height="50" backgroundColor="white"> </Label>
    <Label text="Label 4" width="50" height="50" backgroundColor="white"> </Label>
  </StackLayout>

component.css:

StackLayout {
  margin: 10;
  background-color: green;

}

.stackBorder {
 border: 2px solid red;
   border-radius: 8px;
}

component.ts:

@Component({
    selector: "sdk-child-component",
    moduleId: module.id,
    templateUrl: "./component.html",
    styleUrls: ["./component.css"]
})

Finally I'm unable to see the border in stacklayout.

Renovate answered 25/5, 2017 at 12:37 Comment(0)
W
7

In nativescript supported css properties are border-width, border-color and border-radius. Tag border alone is not possible nor any solid selection.

More info:

https://docs.nativescript.org/ui/styling

Wholehearted answered 25/5, 2017 at 13:17 Comment(0)
H
10

Via html:

<StackLayout borderRadius="30" borderColor="red" borderWidth="3"></StackLayout>

Via css:

StackLayout {
  border-color: red;
  border-width: 3;
  border-radius: 30;
}

More details: https://docs.nativescript.org/ui-and-styling.html#supported-css-properties

Helle answered 26/2, 2019 at 9:43 Comment(0)
W
7

In nativescript supported css properties are border-width, border-color and border-radius. Tag border alone is not possible nor any solid selection.

More info:

https://docs.nativescript.org/ui/styling

Wholehearted answered 25/5, 2017 at 13:17 Comment(0)
S
1

I guess you can use per-side borders. Check this https://www.nativescript.org/blog/per-side-borders-in-nativescript-css

Stephanotis answered 15/3, 2018 at 5:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.