Respond to a native picker - ANDROID

I am trying to add some style for a responsive native collector, like a base and set placeholder, but unable to do this.

const styles = StyleSheet.create({
  picker: {
    textDecorationLine: 'underline'
  }
});

<Picker
   style={[styles.picker]}>
   <Picker.Item label="Country" value="" />
   <Picker.Item label="United States" value="US" />
   <Picker.Item label="India" value="IN" />
</Picker>
  • If I use value = "", then it shows the country as a selectable value that I do not want.
  • textDecorationLine Cannot set underline style for selection.

Basically, I want to create something like this,

enter image description here

where I can also set the placeholder color.

Thanks in adv.

+4
source share
4 answers

Picker Picker Android. Android SpinnerItem android/app/src/res/styles.xml .: ?

, , . Android spinner with underline appcompat

, . , React Native Picker , , Picker undefined.

+2

, Picker TextInput, . : , , , - .

- textDecorationLine, borderBottomWidth .

, selectedValue onValueChange:

selectedValue={this.state.country} onValueChange={(country) => this.setState({country: country})}>
0

:

<!-- Base application theme. -->
<style name="AppTheme">
    <!-- Customize your theme here. -->
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:spinnerStyle">@style/Base.Widget.AppCompat.Spinner.Underlined</item>
    ...
</style>

colorAccent , @style/Base.Widget.AppCompat.Spinner.Underline Picker.

, Android React. android:editTextStyle, android:textViewStyle ..

, React Picker Spinner, AppCompatSpinner, , API < 21.

0

iOS: https://snack.expo.io/r1L7DGb1Z

:

1) itemStyle

2) , . , , TouchableHighlight ( )

3) This is not like Android, so you probably need to add an extra style to the platform.

-1
source

Source: https://habr.com/ru/post/1675361/


All Articles