首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >react-native-dropdown-picker列出的项目未正确显示(覆盖)

react-native-dropdown-picker列出的项目未正确显示(覆盖)
EN

Stack Overflow用户
提问于 2021-05-17 00:11:36
回答 1查看 2.4K关注 0票数 3

我已经用“DropDown -native-dropdown- picker”包创建了反应选取器,所有项目都列出了,但它在另一个组件上看起来是透明的。有人能帮我解决这个问题吗?

下面是我的源代码:

代码语言:javascript
复制
import React, {useState} from 'react';
import {View, Text, Button, ScrollView, StyleSheet} from 'react-native';
import DropDownPicker from 'react-native-dropdown-picker';

  
const App = () => {
  const [myArray, setMyArray] = useState([]);
  const [open, setOpen] = useState(false);
  const [value, setValue] = useState(null);
  const [items, setItems] = useState([
    {label: 'Apple', value: 'apple'},
    {label: 'Banana', value: 'banana'}
  ]);

  return (
      <View style={styles.container}>
        <Button title="Check"/>
        <Text>Hello world</Text>
        <DropDownPicker
          open={open}
          value={value}
          items={items}
          setOpen={setOpen}
          setValue={setValue}
          setItems={setItems}
        />
        <Button title="Check"/>
        <Text>Hello world</Text>
        <Button title="Check"/>
        <Text>Hello world</Text>
        <Button title="Check"/>
        <Text>Hello world</Text>
        <Button title="Check"/>
        <Text>Hello world</Text>
        <Button title="Check"/>
        <Text>Hello world</Text>
      </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    textAlign: 'center',
  },
});
export default App;

预期:列出的项目需要正确显示,没有覆盖,按钮希望显示在滚动视图的下拉列表之后。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-17 00:37:57

问题似乎不仅仅是透明度。如果您注意到,凸起的按钮出现在下拉列表的行上。

这意味着z-index在这里也是一个问题。

DropDownPicker组件添加一个dropDownContainerStyle={{ backgroundColor: 'white',zIndex: 1000, elevation: 1000 }}

这应该可以修复transparencyzIndex

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67558933

复制
相关文章

相似问题

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