AdelRedaa97 / react-native-select-dropdown

react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
MIT License
322 stars 139 forks source link

Dropdown Width adjustment based on the text #133

Closed Manojkumarj closed 6 months ago

Manojkumarj commented 1 year ago

Hi team, Can you please help us to fix the Dropdown Width adjustment based on the text issue in android and ios

AshwinTayson commented 1 year ago

Any solution for this?

rafaellbaptista commented 12 months ago

Hey, this can help!  😄

Artaudd commented 10 months ago

Hey, this can help!  😄

  • On your styles.tsx (or in the same file that you have your StyleSheet): const {width} = Dimensions.get('window');
  • On buttonStyle: width: width / 4 -> Change for what you need

Is there any way to make the width adjust depending on the button text instead of using the same width for every option? (i'm showing the selected option on the button)

rafaellbaptista commented 9 months ago

Hey, this can help!  😄

  • On your styles.tsx (or in the same file that you have your StyleSheet): const {width} = Dimensions.get('window');
  • On buttonStyle: width: width / 4 -> Change for what you need

Is there any way to make the width adjust depending on the button text instead of using the same width for every option? (i'm showing the selected option on the button)

I think you can have a state that stores the length of the selected option text, and pass that state to your styles.tsx. Instead of having width: width / 4, you could have width: [some mathematical formula that you can use the state argument with the length of the selection option text]

That could solve the problem, but not sure, it could be worth trying! Let me know 👍

AdelRedaa97 commented 6 months ago

Fixed in v4.0 take a look at the changes made in v4.0 https://github.com/AdelRedaa97/react-native-select-dropdown?tab=readme-ov-file#-major-changes

Feel free to open the issue again if it still exists