在<view>中反复对齐本机

时间:2017-08-03 11:21:18

标签: css reactjs react-native view

如何将两个项目(图标/文字)对齐?

icon
       text

现在这样对齐:

icon  text

我需要他们像这样

Route::get('api/users/{user}', function (App\User $user) {
return $user->email; });

2 个答案:

答案 0 :(得分:6)

您可以使用flexDirection布置行中的项目。默认为列

<TouchableOpacity
        key = {index}
        onPress = {() => this._onPress(key)}
        style = {containerStyle.container}>
        <View style={containerStyle.rowContainer}>
          <Icon 
            name = {Platform.OS === "ios" ? "ios-checkmark-outline" : "md-checkmark"}
            size = {24}
            style = {{ paddingLeft: 10, color: "#108EE9"}} /> 
          <Text 
            style = {this._createStyleText(key)}>
          {key}
          </Text>
        </View>
  </TouchableOpacity>

const containerStyle = StyleSheet.create({
  container: {
    padding: 8,
    backgroundColor: "#ffffff",
  },
  rowContainer: {
    flexDirection: 'row'
  }
}); 

const textStyle = StyleSheet.create({
  unselectedText: {
      paddingLeft: 45,
      color: "#000000",
      fontWeight: "normal",
  },

}); 

答案 1 :(得分:1)

<View style={{flexDirection:'row'}}>
      <Icon 
        name = {Platform.OS === "ios" ? "ios-checkmark-outline" : "md-checkmark"}
        size = {24}
        style = {{ paddingLeft: 10}} /> 
      <Text 
        style = {this._createStyleText(key)}>
      {key}
      </Text>
     </View>