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

下面是我的源代码:
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;预期:列出的项目需要正确显示,没有覆盖,按钮希望显示在滚动视图的下拉列表之后。
发布于 2021-05-17 00:37:57
问题似乎不仅仅是透明度。如果您注意到,凸起的按钮出现在下拉列表的行上。
这意味着z-index在这里也是一个问题。
向DropDownPicker组件添加一个dropDownContainerStyle={{ backgroundColor: 'white',zIndex: 1000, elevation: 1000 }}。
这应该可以修复transparency和zIndex。
https://stackoverflow.com/questions/67558933
复制相似问题