React-native view auto width by text inside

前端 未结 7 636
刺人心
刺人心 2020-12-12 15:09

As i know, react-native stylesheet doesn\'t supports min-width/max-width property.

I have a view and text inside. The view in auto width doesn\'t resize by inherit t

相关标签:
7条回答
  • 2020-12-12 15:38

    If you want to apply width to View based on <Text> , you can do something like this :

    <View style={styles.container}>
       <Text>
         {text}
       </Text>
    </View>
    
    const styles = StyleSheet.create({
      container: {
        flexDirection:"row",
        alignSelf:"flex-start",
        paddingTop: Constants.statusBarHeight,
        backgroundColor: '#ecf0f1',
        padding: 8,
      }
    });
    

    WORKING DEMO

    0 讨论(0)
提交回复
热议问题