Label position in React Native Picker

Asked

Viewed 528 times

0

I’m using the component Picker of React Native and ta working, listing, selecting and such, only that I can not style it well, I was able to put edge, arrange the size but the text that is inside it I could not move, neither the size of the font nor the position that it will be inside, I tried to put the properties

flexDirection: 'row', alignItems: 'center', justifyContent: 'center' 

in the style of a View that stands over the Picker, in the style of Picker and on the property itemStyle of Picker and none of these worked, in all the text is left, not pasted, but is left and I wanted to center it. Someone can help me?

Code:

<View style={HorariosCommandStyles.containerPickerServicos}>
    <Picker itemStyle={{ paddingLeft: 50, fontSize: 35 }} style={{ width: '90%', height: '100%' }}>
        {this.state.servicos.map(s => <Picker.Item label={s.servico.nome} value={s.servico.id} key={s.id} />)}
    </Picker>
</View>
  • How do you want it to look? Enter the full code with the services.

  • @sant0will As I say in the question I would like to center the text in the middle of the Picker but in general it would be like stylizing that text of Picker.

1 answer

-1

Good! I always change only the text color of the items, and it is in the style of Picker. Try to change the centralization there.

<Picker
    style={styles.txtPicker}
...

</Picker>


txtPicker:{
        color:'#ff0000',
        textAlign:'center',
    },
  • The style of Picker nn is for styling text, and I had already tried this, but vlw msmo like this, some other suggestion?

  • good! already made the test? because that’s how it works here. Obs: with the color, with the alignment, no longer know.

  • I had tested before but tbm tested when I saw his answer and he gives an error saying q the property textAlign nn applies to this type of stylization, has stylization for components and stylization for text, and the textAlign is a property for styling text style of Picker receives stylization for components

Browser other questions tagged

You are not signed in. Login or sign up in order to post.