我是新来 react native 的,我如何修改我的代码来改变下拉列表的不透明度,以使文本‘我的文本’变为隐藏?
以下是我的代码:
import React, { useState } from 'react';
import {
Text,
useColorScheme,
View,
Image,
} from 'react-native';
import { Colors } from 'react-native/Libraries/NewAppScreen';
import DropDownPicker from 'react-native-dropdown-picker';
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
const [open, setOpen] = useState(false);
const [value, setValue] = useState(null);
const [items, setItems] = useState([
{
label: 'Option 1',
value: 'option1',
},
{
label: 'Option 2',
value: 'option2',
},
{
label: 'Option 3',
value: 'option3',
},
]);
return (
<View style={{
backgroundColor: "white",
flex: 1,
alignItems: 'center',
justifyContent: 'center',
paddingHorizontal: 15
}}>
<Text>Selected Value: {value}</Text>
<DropDownPicker
open={open}
value={value}
items={items}
setOpen={setOpen}
setValue={setValue}
setItems={setItems}
placeholder="Select an option"
containerStyle={{ width: 400, backgroundColor: "white"}}
listItemLabelStyle={{ fontSize: 16 }}
showArrowIcon={true}
hideSelectedItemIcon={true}
theme="LIGHT"
/>
<Text>My text</Text>
</View>
);
}
export default App;
我已try 添加选项
listParentContainerStyle={{backgroundColor: 'rgba(255, 255, 255, 1)'}}
但没有效果. 我试着按照这里的说明go 做,但没有效果:react-native-dropdown-picker listed items not showing properly (Overlay).