I am trying to aline a Icon and a Text inline and align the text to the left and the icon to the right...
This is how it is looking at the moment:
However, I want to have the text aligned to the left and the icon to the right and also both on the same height...
My code so far:
<Text
style={{
fontSize: 16,
paddingTop: 15,
paddingBottom: 15,
paddingLeft: 10,
paddingRight: 10,
color: "black"
}}
>
Kategorien:
<Icon
style={{
alignItems: "center",
justifyContent: "center",
textAlign: "right"
}}
name="keyboard-arrow-down"
type="MaterialIcons"
/>
</Text>
I also tried to use the react native elements and make use of the right and left element, however, in this case the icon and text is not inline...
<View>
<Left>
Text...
</Left>
<Right>
Icon...
</Right>
</View>
You guys have any idea?
To add space between two elements on the same line in React Native, we can set justifyContent to 'space-between' in the View . to set the flexDirection to 'row' and the justifyContent style to 'space-between' to spread the Text components on the screen.
You need wrap with a View your Text and Icon component. And you can set just padding horizontal and vertical in there.
<View style={{
paddingVertical: 15,
paddingHorizontal: 10,
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center"
}}>
<Text style={{
fontSize: 16,
color: "black"
}}>Kategorien:</Text>
<Icon/>
</View>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With