Ela*_*n r 4 javascript reactjs react-native react-native-dropdown-picker
我使用“react-native-dropdown-picker”包创建了 DropDown 选择器,所有项目都列出了,但它在另一个组件上看起来是透明的。任何人都可以帮我解决这个问题吗?
这是我的源代码:
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;
Run Code Online (Sandbox Code Playgroud)
预期:列出的项目需要正确显示而不重叠,按钮希望出现在带有滚动视图的下拉列表之后。
问题似乎不仅仅在于透明度。如果您注意到,凸起的按钮出现在下拉菜单的行上方。
这意味着z-index这里也是一个问题。
将 a 添加dropDownContainerStyle={{ backgroundColor: 'white',zIndex: 1000, elevation: 1000 }}到您的DropDownPicker组件中。
这应该可以修复transparency以及zIndex.
| 归档时间: |
|
| 查看次数: |
12583 次 |
| 最近记录: |