I’m using React Native Expo, and I encountered an error when trying to set the size of my Viewer to fit the selection menu and number input.
View Code:
<View style={{
flex: 1,
flexDirection: 'row',
alignItems: 'center',
backgroundColor: "black",
width: "100%"
}}>
<SelectList
setSelected={(val) => setSelected(val)}
data={data}
save="value"
placeholder="Produto"
/>
<TextInput
style={{ width: "50%" }}
label="Quantia"
returnKeyType="done"
value={delivery}
onChangeText={(text) => setDelivery(text)}
/>
</View>
App Image ( the black background is for testing, just to know how much space is occupied by the View )
https://media.discordapp.net/attachments/873959321376018462/1087615947638050847/Screenshot_20230321-025022_Expo_Go.jpg?width=224&height=473
What can I do to make the background black only in the menu and in the input?
2
Answers
you are giving BgColor property to whole container insted you need to give bgcolor style to InnerView which holds TextInput Property and SelectList!
Is just that only the thing or you are looking for any other result?
You just need to remove the
flex: 1
on theView
that contains theSelectList
and theTextInput
. The propertyflex
define how your items fill the available space. Your code will seem like this:I suggest you read the documentation about Layout with FlexBox. For this case, you can use the Expo Playground code example in the Flex section to see how the property works.