React-native view auto width by text inside

前端 未结 7 634
刺人心
刺人心 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 , you can do something like this :

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

    WORKING DEMO

提交回复
热议问题