В регулярном выражении, основанном на java, вы можете использовать [\s\S]
Вы можете использовать flex-end
, flex-start
, center
для горизонтального выравнивания предметов. Вы должны добавить flex direction :'row'
в родительский компонент
buttonContainer: {
justifyContent: 'flex-end',}
Просто добавьте justifyContent: 'space -ween', alignItems: 'center' к styles.listitems. Это решит вашу проблему.
Это лучше, я думаю.
renderItem={(info) => (
<TouchableOpacity style={styles.itemWrapper} onPress={() => this.props.selected(info.item.key)}>
<View style={styles.itemImageContainer}>
<Image resizeMode="contain" source={info.item.image} style={styles.image} />
<Text>{info.item.value}</Text>
</View>
<View style={styles.button}>
<Button title="Confirm" color="blue" onPress={this.props.itemDelete}></Button>
</View>
</TouchableOpacity>
)}
const styles = StyleSheet.create({
itemWrapper: {
flex:1,
height: 70,
marginTop: 5,
backgroundColor: "lightgrey",
padding: 10,
flexDirection: 'row',
},
itemImageContainer: {
flex: 2,
alignItems: 'center',
},
image: {
marginRight: 8,
height: 30,
width: 40,
},
buttonContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
}
})
import React, { Component } from 'react';
import { View, Text, StyleSheet, TouchableOpacity, FlatList, Image, Button } from 'react-native';
export default class ListItems extends Component {
constructor(props) {
super(props);
}
render() {
return (
<FlatList
data={this.props.text}
renderItem={(info) => (
<TouchableOpacity onPress={() => this.props.selected(info.item.key)}>
<View style={styles.listitems}>
<View>
<Image resizeMode="contain" source={info.item.image} style={styles.image} />
<Text>{info.item.value}</Text>
<View>
<View style={styles.button}>
<Button title="Confirm" color="blue" onPress={this.props.itemDelete}></Button>
</View>
</View>
</TouchableOpacity>
)}
>
</FlatList>
);
}
}
const styles = StyleSheet.create({
listitems: {
width: "100%",
flex:1,
marginTop: 5,
backgroundColor: "lightgrey",
padding: 10,
flexDirection: 'row',
justifyContent:'space-between`enter code here`'
},
image: {
marginRight: 8,
height: 30,
alignItems: "center",
width: 40,
},
button: {
width: "40%",
alignItems: 'flex-end',
}
})