【问题标题】:Align right modal drop down in React Native using 'react-native-modal-dropdown'使用“react-native-modal-dropdown”在 React Native 中对齐右模式下拉菜单
【发布时间】:2017-05-10 09:50:28
【问题描述】:

我有一段代码使用“react-native-modal-dropdown”在 React Native 中显示下拉菜单

  <View style = {{alignItems:'center',}}>
        <TouchableOpacity onPress = {()=>{this.dropDown && this.dropDown.show();}}>
           <View style = {{width:170,height:40, alignItems:'center',flexDirection:'row'}}>
              <ModalDropdown ref={(el) => {this.dropDown = el}}
              options={["A", "B", "C"]}
              defaultValue = {"A"}
                             style = {{ flex: 1}}
                             textStyle = {{fontWeight:'bold', textAlign: 'right'}}
                             onSelect = {(index,value)=>{this.onClickDropDown(value)}}
                             dropdownStyle={{width:170, }}
                             renderRow={this._dropdown_renderRow.bind(this)}
              />
               <Text>▼</Text>
            </View>
        </TouchableOpacity>
   </View>

结果是“A”后面显示的下拉菜单:enter image description here

我希望下拉菜单显示后面的“▼”,这是正确的。 enter image description here

你能帮帮我吗?非常感谢。

【问题讨论】:

    标签: reactjs react-native modal-dialog dropdown justify


    【解决方案1】:
    <TouchableOpacity onPress = {()=>{this.dropDown && this.dropDown.show();}}>
        <View style = {{height:40, alignItems:'center',flexDirection:'row'}}>
            <ModalDropdown ref={(el) => {this.dropDown = el}}
            options={["A", "B", "C"]}
            defaultValue = {"A"}
                            style = {{ flex: 1,paddingRight:30}}
                            textStyle = {{fontWeight:'bold', textAlign: 'right'}}
    
                            dropdownStyle={{width:170, }}
    
            />
            <View style={{ position: "absolute", right: 10, top: 10 }}><Text>▼</Text></View>
        </View>
    </TouchableOpacity>
    

    【讨论】:

    • 不鼓励仅使用代码回答。请花时间解释什么以及为什么这可以解决问题!
    猜你喜欢
    • 2022-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 2022-11-17
    相关资源
    最近更新 更多