React Native向文本添加边框

时间:2017-01-15 19:27:51

标签: react-native react-native-android

我想在Text组件周围添加边框。我已经完成了以下操作,但是我只想要文本边框,而不是视图的整个宽度。

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
  <form>
  <input type="text" ng-model="name1"/>
  <input type="text" ng-model="age1"/>
  <button type="submit" ng-click="send1();">Form 1</button>
  </form><br>
    <form>
  <input type="text" ng-model="option.name1"/>
  <input type="text" ng-model="option.age1"/>
  <button type="submit" ng-click="send2(option);">Form 2</button>
  </form>
</div>

enter image description here

这可能吗?

1 个答案:

答案 0 :(得分:3)

是的,您可能需要将其包装在另一个视图中:

   <View style={styles.container}>
        <View style={styles.inner}>
  <Text>A DIFFERENT EXPERIENCE</Text>
        </View>
      </View>

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
    borderWidth:4
  },
  inner:{
  borderWidth:4

  }

干杯:)