Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to wrap the react-native <picker /> for the lengthy item text? #23887

Closed
ashwithags opened this issue Mar 13, 2019 · 4 comments
Closed

How to wrap the react-native <picker /> for the lengthy item text? #23887

ashwithags opened this issue Mar 13, 2019 · 4 comments
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@ashwithags
Copy link

ashwithags commented Mar 13, 2019

🐛 Bug Report

I have designed a picker using react native-base, and I'm trying to style it using styles.XML BUT its not working. I want my drop down items to wrap in second line when the length of the text exceeds the width.

Current Behavior

image

Expected Behavior

instead of dots text should come to next line
image

Code Example

class PickerExample extends Component {
state = {link: ''}
updateLink = (link) => {
  this.setState({ link: link })
}
render() {
  return (
     <View>
        <Picker selectedValue = {this.state.link} onValueChange = {this.updateLink}>
           <Picker.Item label = "25 best small-business apps in 2018 - nerdwallet" value = "one" />
           <Picker.Item label = "Top business apps, best apps for small business" value = "two" />
           <Picker.Item label = "Collaboration & productivity apps for business" value = "three" />
        </Picker>
        <Text style = {styles.text}>{this.state.link}</Text>
     </View>
   )
}
}
export default PickerExample;

Styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
</style>

<style name="SpinnerItem" parent="Theme.AppCompat.Light.NoActionBar">>
    <item name="android:fontFamily">segoe-ui</item>
</style>

<style name="SpinnerDropDownItem" parent="Theme.AppCompat.Light.NoActionBar">>
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">wrap_content</item>   
    <item name="android:singleLine">false</item>
</style>

Environment

Environment:
OS: Windows 10
Node: 11.9.0
Yarn: 1.13.0
npm: 6.5.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842

Packages: (wanted => installed)
react: 16.3.2 => 16.3.2
react-native: 0.59.0 => 0.59.0

@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write `[skip envinfo]` alongside an explanation in your Environment: section.

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.59 and verify if the issue still exists.

The "Resolution: Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@thymikee
Copy link
Contributor

Since this issue is about a Native Base component, please file this issue in native-base repository: https://github.com/GeekyAnts/NativeBase/issues/new. Thanks!

@PavanKumar-sa
Copy link

React Native 0.60.3 still issue exists in android and picker text doesn't get wrapped to next line. Any fixes for this? iOS works fine.

@facebook facebook locked as resolved and limited conversation to collaborators May 30, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants