javascript - React native - text not wrappingshrinking - Stack Overflow

I have some text overflowing my container view.I would like the word that appears cut in the picture to

I have some text overflowing my container view.I would like the word that appears cut in the picture to be moved to the second line. I have tried textShrink as proposed in similar posts, but it doesn't work, so I must be doing something wrong in a parent view???. Can you see it?

<View style={styles.container}>
<ScrollView style={styles.scrollview}>
(...)
 <View style={styles.line}>
          <View style={[styles.bubble2,{}]}>
            <Text style={{color:'white', fontSize:18, flexShrink:1}}>{strings('profilescreen.birthday')}</Text> 
          </View>
          <Text style={styles.maintext}>{userInfo.birthday}</Text>
        </View>
(...)
      </ScrollView>
    </View>

styles:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: Colors.pointo,
    paddingTop: Constants.statusBarHeight+10,

  },

  bubble2:{
    height: 40,
    width:130,
    borderRadius:25,
    backgroundColor: Colors.pointosecondary,
    paddingHorizontal:20,
    alignSelf:'flex-start',
    alignItems:'center',
    justifyContent:'center',
    marginHorizontal:5,
    flexDirection:'column',

  },

  scrollview:{
    backgroundColor:'#fFF',
    height:'100%',
    paddingTop:10,
  },
  line:{
    height:50,
    flexDirection:'row',
    alignItems:'center',
    paddingHorizontal:20,
    paddingTop:15,
    flex:1,
  },
  maintext:{
    color:'gray',
    fontSize:16,
    paddingLeft:20,
  },
  
})

I have some text overflowing my container view.I would like the word that appears cut in the picture to be moved to the second line. I have tried textShrink as proposed in similar posts, but it doesn't work, so I must be doing something wrong in a parent view???. Can you see it?

<View style={styles.container}>
<ScrollView style={styles.scrollview}>
(...)
 <View style={styles.line}>
          <View style={[styles.bubble2,{}]}>
            <Text style={{color:'white', fontSize:18, flexShrink:1}}>{strings('profilescreen.birthday')}</Text> 
          </View>
          <Text style={styles.maintext}>{userInfo.birthday}</Text>
        </View>
(...)
      </ScrollView>
    </View>

styles:

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: Colors.pointo,
    paddingTop: Constants.statusBarHeight+10,

  },

  bubble2:{
    height: 40,
    width:130,
    borderRadius:25,
    backgroundColor: Colors.pointosecondary,
    paddingHorizontal:20,
    alignSelf:'flex-start',
    alignItems:'center',
    justifyContent:'center',
    marginHorizontal:5,
    flexDirection:'column',

  },

  scrollview:{
    backgroundColor:'#fFF',
    height:'100%',
    paddingTop:10,
  },
  line:{
    height:50,
    flexDirection:'row',
    alignItems:'center',
    paddingHorizontal:20,
    paddingTop:15,
    flex:1,
  },
  maintext:{
    color:'gray',
    fontSize:16,
    paddingLeft:20,
  },
  
})
Share Improve this question edited Sep 16, 2020 at 18:15 Mireia asked Sep 16, 2020 at 10:13 MireiaMireia 3332 gold badges3 silver badges15 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

Use flexWrap

Update your text ponent style like this:

<Text style={{color:'white', fontSize:18, flexShrink:1, flexWrap: 'wrap'}}>
  {strings('profilescreen.birthday')}
</Text> 

CodeSandbox example

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742391678a4435137.html

相关推荐

  • javascript - React native - text not wrappingshrinking - Stack Overflow

    I have some text overflowing my container view.I would like the word that appears cut in the picture to

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信