一行展示2個(gè)控件,一個(gè)居右,一個(gè)居中,類(lèi)似下圖這種

image.png
現(xiàn)在最外面設(shè)置一個(gè)橫向布局,中間的控件居中用justifyContent和alignItems展示,右邊的控件居右,使用絕對(duì)布局,right: 4,距離右邊邊緣4個(gè)單元
代碼如下:
<View
style={{
backgroundColor: "#fff",
height: 40,
flexDirection: "row",
// justifyContent: "space-around",
}}
>
<View
style={[
{
justifyContent: "center",
alignItems: "center",
flex:1
},
]}
>
<Text
style={{
fontWeight: "bold",
fontSize: 13,
textAlign: "center",
}}
numberOfLines={2}
>
{'測(cè)試'}
</Text>
</View>
<View style={{
justifyContent: "center",
alignItems:'center',
right: 4,
position: 'absolute',
}}>
<Image
source={imageDown}
style={{ height: 20, width: 20,marginLeft:20 }}
></Image>
</View>
</View>