更改样式反应本地材料下拉菜单

时间:2020-05-19 06:04:13

标签: react-native

native-material-dropdown`,我想在下图中创建此下拉列表: enter image description here

但左边的箭头: enter image description here 我该如何更改为左?这是我的代码如下:

  < Dropdown
        renderAccessory={() => (
          <Image resizeMode="contain" source={combo_arrow_icon} style={{ marginTop: 5, justifyContent: 'center', }}/>
        )}
        inputContainerStyle={{ borderBottomColor: 'transparent' }}
        onChangeText={(value) => props.newHandelChange(value)}
        dropdownMargins={{ min: 15, max: 15 }}
        dropdownOffset={{ top: 10, left: 0 }}
        dropdownPosition={- 5}
        style={{ marginTop: 5, fontWeight: 'bold', fontFamily: 'IRANSansMobile', fontSize: 16, textAlign: 'right', }}
        itemTextStyle={{ textAlign: 'center', fontFamily: 'IRANSansMobile' }}
        absoluteRTLLayout={false}
        containerStyle={{ backgroundColor: '#59c5b8', borderWidth: 0.5, borderRadius: 1, marginLeft: 16, marginRight: 16, marginBottom: 8, fontSize: 18, fontFamily: 'IRANSansMobile' }}
        data={props.data ? props.data : dataGroup}
        placeholder="(پیش فرض گروه فعال)..."
        placeholderTextColor='#000'
        placeholderStyle={{ fontWeight: '200', fontFamily: 'IRANSansMobile', }}
      />

1 个答案:

答案 0 :(得分:2)

您有两种选择可以处理该问题,

1。您需要对应用程序RTL进行布局,以便所有内容都会自动处理。有关更多信息= >>

--- https://reactnative.dev/blog/2016/08/19/right-to-left-support-for-react-native-apps

--- Right to Left in react-native

  1. 您还需要通过转到./node_module/react-native-material-dropdown/src/component/dropdown/styles.js来更改DropDown的默认样式,并执行以下操作: 从react native导入尺寸并添加 const {width,height}=Dimensions.get('window'),然后转到附件样式,并在末尾添加right:width*.94, 通过这样做,您将可以得到一些结果,例如: enter image description here