使用' react-native-modal-dropdown'在React Native中对齐右模态下拉列表。

时间:2017-05-10 09:50:28

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

我有一个代码,显示使用' 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>

结果是显示在&#34; A&#34;:enter image description here

背后的下拉菜单

我希望下拉菜单显示落后&#34;▼&#34;,它是正确的。 enter image description here

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

1 个答案:

答案 0 :(得分:0)

<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>