开发者

How to align the first item left, and the second right in a row in react native?

开发者 https://www.devze.com 2022-12-07 17:17 出处:网络
I put two items (e.g. two buttons) in one row. I want to align the firs开发者_如何学JAVAt item left, and align the second item right, which looks like:

I put two items (e.g. two buttons) in one row. I want to align the firs开发者_如何学JAVAt item left, and align the second item right, which looks like:

How to align the first item left, and the second right in a row in react native?

How to achieve this in react native using flex?


After some digging, I found there're two easy ways to achieve this:

// first way
<View style={{flexDirection: "row", justifyContent: "space-between"}}>
<Button>B1</Button> // align left
<Button>B2</Button> // align right
</View>

// second way
<View style={{flexDirection: "row"}}>
<Button>B1</Button> // align left
<Button style={{marginLeft: "auto"}}>B2</Button> // align right
</View>
0

精彩评论

暂无评论...
验证码 换一张
取 消