首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应-本机-选择-选择不使用父视图{挠性方向:‘行’}

反应-本机-选择-选择不使用父视图{挠性方向:‘行’}
EN

Stack Overflow用户
提问于 2019-11-07 10:37:00
回答 2查看 4.8K关注 0票数 2

我想在一行中使用<RNPickerSelect./><TextInput/>。因此,当我创建父flexDirection: row时,我只看到箭头而没有文本。即使我删除了<TextInput/>,也没有看到任何文本。

代码语言:javascript
复制
import React, { Component } from 'react';
import {
    StyleSheet,
    View,
} from 'react-native';
import RNPickerSelect from 'react-native-picker-select';

type Props = {}

const countryCode = [
{
    label: '+91',
    value: '+91',
},
{
    label: '+1',
    value: '+1',
},
{
    label: '+2',
    value: '+2',
},
];

export default class PickerTest extends Component<Props> {

constructor() {
    super()
    this.state = {
        phoneNumber: "",
        countryCode: ""
    }
}

render() {
    return (
        <View style={{flexDirection:'row'}}>
            <View paddingVertical={5}>
            {/* and hiding the InputAccessoryView on iOS */}
            <RNPickerSelect
            placeholder={{}}
            items={countryCode}
            onValueChange={value => {
            this.setState({
                countryCode: value,
            });
            }}
            InputAccessoryView={() => null}
            style={pickerSelectStyles}
            value={this.state.countryCode}
            />
            </View>
        </View>
    );
}
}

const pickerSelectStyles = StyleSheet.create({
inputIOS: {
    fontSize: 16,
    paddingVertical: 12,
    paddingHorizontal: 10,
    borderWidth: 1,
    borderColor: 'gray',
    borderRadius: 4,
    color: 'black',
    paddingRight: 30, // to ensure the text is never behind the icon
},
inputAndroid: {
    fontSize: 16,
    paddingHorizontal: 10,
    paddingVertical: 8,
    borderWidth: 0.5,
    borderColor: 'purple',
    borderRadius: 8,
    color: 'black',
    paddingRight: 30, // to ensure the text is never behind the icon
},
});

在运行上面的应用程序时,我得到了这样的信息

如您所见,选择器没有显示文本。

下面是我正在使用的配置

react本机-选择版本: 6.3.3

react原生版本: 0.61.2

反应版本: 16.9.0

EN

回答 2

Stack Overflow用户

发布于 2019-11-19 16:19:52

这是一个上游问题:https://snack.expo.io/HkygCqhsr

选项:

  1. useNativeAndroidPickerStyle
  2. 套装widthheightinputAndroid风格的道具
票数 1
EN

Stack Overflow用户

发布于 2021-04-19 18:01:11

向RNPickerSelect中添加atribute“RNPickerSelect”,并使用溢出选项:‘隐藏’

代码语言:javascript
复制
<RNPickerSelect style={styles.selectContainer}
                ...
                pickerProps={{ style: { height: 214, overflow: 'hidden' } }}
                ...
            />
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58746878

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档