React Native: ScrollView and Layout Elements with flex - react-native

Hi i'm trying to add a ScrollView but it doesn't work like expected.
If i add flex:1 to ScrollView then i can style the child elements but there is no scroll bar so i can't scroll.
If I remove flex:1 or change it to flexGrow then i have the scrollbar but the styles are broken on the child elements.
How i can add i ScrollView and the styles to the childs?
I need some Information why is it happen. Thank you.
import React, { useContext, useState, useEffect } from 'react';
import {
Text,
TextInput,
StyleSheet,
View,
TouchableOpacity,
Alert,
ScrollView,
} from 'react-native';
import { globalStyles } from '../styles/global';
import colors from '../styles/color';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import Feather from 'react-native-vector-icons/Feather';
import * as Animatable from 'react-native-animatable';
import Button from '../components/Button';
const SignInScreen = (props) => {
return (
<View style={styles.container}>
<ScrollView contentContainerStyle={styles.scrollViewContainer}>
<View style={styles.containerTop}>
<Text style={globalStyles.h1}>Login</Text>
</View>
<View style={styles.containerBottom}>
<View style={styles.viewAction}>
<FontAwesome name='user-o' color='#ccc' size={20} style={{ width: 20 }} />
<TextInput
style={[styles.input]}
placeholder="Your Email"
value={data.email}
autoCapitalize='none'
onChangeText={(val) => textInputEmailChange(val)}
/>
</View>
<View style={styles.viewAction}>
<FontAwesome name='lock' color='#ccc' size={20} style={{ width: 20 }} />
<TextInput
style={[styles.input]}
placeholder="Password"
value={data.password}
autoCapitalize='none'
secureTextEntry={data.secureTextEntry ? true : false}
onChangeText={(val) => handlePasswordChange(val)}
/>
<TouchableOpacity onPress={updateSecureTextEntry}>
{data.secureTextEntry ? <Feather name='eye-off' color='#ccc' size={20} style={{ width: 20 }} />
: <Feather name='eye' color='#80c904' size={20} style={{ width: 20 }} />
}
</TouchableOpacity>
</View>
{uiErrors.errors ? (<Text style={styles.errorMsg}>{uiErrors.errors}</Text>) : (<Text></Text>)}
<Button
content={'Login'}
buttonStyles={{ marginVertical: 20, paddingVertical: 15, }}
onPress={handleLogin}
/>
<Button
content={'Login'}
buttonStyles={{ marginVertical: 20, paddingVertical: 15, }}
onPress={handleLogin}
/>
<Button
content={'Login'}
buttonStyles={{ marginVertical: 20, paddingVertical: 15, }}
onPress={handleLogin}
/>
<Button
content={'Login'}
buttonStyles={{ marginVertical: 20, paddingVertical: 15, }}
onPress={handleLogin}
/>
<Button
content={'Login'}
buttonStyles={{ marginVertical: 20, paddingVertical: 15, }}
onPress={handleLogin}
/>
<Button
content={'Create an account'}
buttonStyles={{ backgroundColor: 'transparent' }}
textStyles={styles.signUpBtnText}
onPress={() => { navigation.navigate('SignUp'); }}
/>
</View>
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: colors.light_theme.splashgb,
},
scrollViewContainer: {
// flex: 1,
// flexGrow: 1,
// justifyContent: 'space-between'
},
containerTop: {
flex: 1, // it add this only if flex:1 is added to scrollViewContainer but the then i can't scroll.
padding: 25,
backgroundColor: 'blue'
},
containerBottom: {
flex: 1,
padding: 25,
flexDirection: 'column',
backgroundColor: colors.light_theme.container,
borderTopLeftRadius: 25,
borderTopRightRadius: 25,
},
viewAction: {
flexDirection: 'row',
width: '100%',
borderBottomWidth: 1,
borderBottomColor: colors.light_theme.lightgray,
paddingVertical: 0,
alignItems: 'center',
},
input: {
flex: 1,
padding: 15,
},
text: {
color: colors.light_theme.white,
},
errorMsg: {
color: colors.light_theme.errorMsg,
fontSize: 14,
marginVertical: 5,
},
signUpBtnText: {
color: colors.light_theme.primary
}
});
export default SignInScreen;

1: Put your ScrollView inside a View:
... <View><ScrollView> ... </ScrollView></View> ...
2: Remove "flex:1" from your scrollViewContainer style so it will be only with felxGrow and justifyContent

Related

FlatList - react native not scrolling

I am unable to get my Flatlist to scroll in my expo react native app. At the moment it is just static, displaying a grid of images int he Flatlist with no scrolling functionality. Please can someone advise?
I am unable to get my Flatlist to scroll in my expo react native app. At the moment it is just static, displaying a grid of images int he Flatlist with no scrolling functionality. Please can someone advise?
import { StyleSheet, Text, View, Button, TextInput, TouchableWithoutFeedback, Keyboard, FlatList, ActivityIndicator } from 'react-native';
import { Image } from '#rneui/themed';
import ImageAPI from '../shared-components/ImageAPI';
export default function Home({ navigation }) {
const onCreate = () => {
console.log('create my image now');
};
return (
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<View style={styles.container}>
{/** Enter text prompt */}
<View style={styles.section1}>
<View style={styles.txtInputView}>
<TextInput
style={styles.txtInput}
placeholder='Enter a prompt - a description of what you want to create'
multiline={true}
numberOfLines={4}
/>
</View>
<View style={styles.buttonView}>
<Text
style={styles.createBtnText}
onPress={onCreate}
>Create</Text>
</View>
</View>
{/** PROMPT EXAMPLES */}
<View style={styles.section2}>
<View style={styles.section2_sub0}>
<Text style={styles.promptEgTxt}>Prompt Examples</Text>
</View>
<View style={styles.section2_sub1}>
<ImageAPI />
</View>
</View>
</View>
</TouchableWithoutFeedback>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
section1: {
flex: 2,
width: '100%',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#ffc6e2',
},
section2: {
flex: 5,
width: '100%',
backgroundColor: '#F8DB93',
},
// section3: {
// flex: 3,
// backgroundColor: '#BCF893',
// },
txtInputView: {
flex: 3,
width: '85%',
height: '50%',
alignItems: 'center',
justifyContent: 'center',
marginTop: 20,
marginBottom: 20
},
buttonView: {
flex: 2,
width: '70%',
alignItems: 'center',
justifyContent: 'center',
marginBottom: 20,
backgroundColor: '#EE4A4A',
borderRadius: 40
},
txtInput: {
borderColor: '#AAAAAA',
borderWidth: 2,
padding: 10,
borderRadius: 15,
// width: '85%',
// height: '50%',
width: '100%',
height: '100%',
fontSize: 15,
},
createBtnText: {
fontSize: 18,
fontWeight: 'bold',
// backgroundColor: '#EEEC4A'
},
section2_sub0: {
flex: 1,
width: '100%',
height: '100%',
backgroundColor: '#EEEC4A',
justifyContent: 'center',
},
promptEgTxt: {
fontSize: 15,
fontWeight: 'bold',
marginLeft: 10
},
section2_sub1: {
flex: 8,
width: '100%',
height: '100%',
backgroundColor: '#A9F889'
},
});
This is the ImageAPI.js file:
import React from 'react';
import { FlatList, SafeAreaView, StyleSheet, ActivityIndicator, View, ScrollView } from 'react-native';
import { Image } from '#rneui/themed';
const BASE_URI = 'https://source.unsplash.com/random?sig=';
const ImageAPI = () => {
return (
<>
<SafeAreaView>
<FlatList
data={[...new Array(10)].map((_, i) => i.toString())}
style={styles.list}
numColumns={2}
keyExtractor={(e) => e}
renderItem={({ item }) => (
<Image
transition={true}
source={{ uri: BASE_URI + item }}
containerStyle={styles.item}
PlaceholderContent={<ActivityIndicator />}
/>
)}
/>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
list: {
width: '100%',
backgroundColor: '#000',
},
item: {
aspectRatio: 1,
width: '100%',
flex: 1,
},
});
export default ImageAPI
you need to give it a fixed height and set the contentContainerStyle prop to { flexGrow: 1 }. This will allow the content inside the FlatList to exceed the bounds of the container and be scrollable.
<View style={styles.section2_sub1}>
<FlatList
contentContainerStyle={{ flexGrow: 1 }}
data={data}
renderItem={({ item }) => <ImageAPI data={item} />}
keyExtractor={(item) => item.id}
/>
</View>
Try adding flex according to your requirement to your <SafeAreaView> which is the parent to your <Flatlist> Something like this:
<>
<SafeAreaView style = {{flex: 8}} >
<FlatList
data={[...new Array(10)].map((_, i) => i.toString())}
style={styles.list}
numColumns={2}
keyExtractor={(e) => e}
renderItem={({ item }) => (
<Image
transition={true}
source={{ uri: BASE_URI + item }}
containerStyle={styles.item}
PlaceholderContent={<ActivityIndicator />}
/>
)}
/>
</SafeAreaView>
</>
Or remove the SafeAreaView if not required.
Both should work.

It shows an error while rendering methods in HomeScreen

import React from "react";
import {
SafeAreaView,
ScrollView,
StyleSheet,
Text,
TextInput,
TouchableOpacity,
View,
} from "react-native";
// import Header from "../src/components/molecules/Header";
import ListItem from "../src/components/molecules/ListItem";
import colors from "../src/res/colors";
import fonts from "../src/res/fonts";
// import images from "../src/res/images/Illustration";
import {
IC_Search,
IL_House_01,
IL_House_02,
IL_House_03,
IL_House_04,
IL_House_05,
} from "../src/res/images1";
const HomeScreen = ({ navigation }) => {
return (
<SafeAreaView style={styles.screen}>
<ScrollView showsVerticalScrollIndicator={false}>
{/* header */}
{/* <Header /> */}
{/* welcome text */}
<View style={styles.wrapperWelcome}>
<Text style={styles.textWelcome}>Find</Text>
<Text style={styles.textWelcome}>Your Dream Home</Text>
</View>
{/* search section */}
<View style={styles.wrapperSearch}>
<View style={styles.wrapperTxtInput}>
<TextInput
placeholder="Find your dream home"
style={styles.txtInput}
/>
{/* btn search */}
<View style={styles.wrapperBtnSearch}>
<TouchableOpacity>
<IC_Search />
</TouchableOpacity>
</View>
</View>
</View>
{/* content */}
<View>
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
style={styles.wrapperContent}
>
<ListItem
type="main"
name="Modern House"
city="Bandung"
image={IL_House_01}
onPress={() => navigation.navigate("Detail")}
/>
<ListItem
type="main"
name="White House"
city="Bandung"
image={IL_House_02}
/>
<ListItem
type="main"
name="Wooden House"
city="Bandung"
image={IL_House_05}
/>
</ScrollView>
{/* recommend section */}
<View style={styles.wrapperRecommend}>
<Text style={styles.textTitleRecommend}>Recommended For You</Text>
<ListItem name="Wooden House" city="Bandung" image={IL_House_05} />
<ListItem
name="Triangle House"
city="Bandung"
image={IL_House_03}
/>
<ListItem name="Hill House" city="Bandung" image={IL_House_04} />
</View>
</View>
</ScrollView>
</SafeAreaView>
);
};
export default HomeScreen;
const styles = StyleSheet.create({
screen: { flex: 1, backgroundColor: "#f8f8ff" },
wrapperWelcome: { paddingHorizontal: 20 },
textWelcome: {
fontSize: 30,
// fontFamily: fonts.SemiBold,
},
wrapperSearch: {
paddingHorizontal: 20,
marginTop: 30,
shadowColor: "#708090",
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.22,
shadowRadius: 2.22,
elevation: 3,
},
wrapperTxtInput: {
flexDirection: "row",
backgroundColor: "#f8f8ff",
height: 55,
width: "100%",
borderRadius: 28,
alignItems: "center",
justifyContent: "space-between",
paddingHorizontal: 20,
},
txtInput: { fontSize: 14 },
// fontFamily: fonts.Regular
wrapperBtnSearch: {
backgroundColor: "#4d79ff",
height: 39,
width: 39,
borderRadius: 39 / 2,
justifyContent: "center",
alignItems: "center",
},
wrapperContent: {
marginTop: 30,
paddingLeft: 20,
flexDirection: "row",
paddingVertical: 10,
},
wrapperRecommend: { marginTop: 30, paddingHorizontal: 20 },
textTitleRecommend: { fontSize: 16 },
// fontFamily: fonts.SemiBold,
});
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of HomeScreen.
Why do I get like this?

React Native Card Styling

How to stretch the content of the card so it has 100% width. For example I want the red paragraph to touch the edges horizontally so there won't be yellow space on the right and left. In other words I would like to remove the padding from the cad content so there will be no yellow shown.
Here is my code:
import React,{Component} from 'react';
import { Searchbar, Button, Card, Paragraph } from 'react-native-paper';
import { StyleSheet, SafeAreaView, View, ActivityIndicator, StatusBar, TextInput, Text } from 'react-native';
import { FlatList, TouchableOpacity } from 'react-native-gesture-handler';
render()
{
const styles = StyleSheet.create({
container: {
flex: 1,
},
menuContainer:{
// backgroundColor: 'orange',
borderRadius: 10,
margin: 10,
marginTop: 2,
},
menuItemHeader:{
backgroundColor: '#D9B611',
borderRadius: 10,
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0,
},
menuItemHeaderText:{
marginTop:5,
fontSize:17,
fontWeight:'bold',
color:'#fff'
},
menuItemHeaderSubText:{
marginTop:5,
fontSize:15,
color:'#fff'
},
menuItemBody:{
backgroundColor: 'yellow',
borderWidth:1,
borderBottomRightRadius: 5,
borderBottomLeftRadius: 5,
borderColor: 'gray',
borderTopWidth: 0,
alignSelf: 'stretch',
},
menuItemBodyText:{
marginTop:5,
fontSize:15,
},
description_input: {
height: 150,
backgroundColor: 'red',
alignItems: this.multiline ? 'flex-start' : 'center',
},
action_buttons_positioning: {
alignSelf: 'flex-end',
backgroundColor: 'green',
},
action_buttons: {
width: 50,
elevation: 8,
// backgroundColor: "#D9B611",
backgroundColor: "gray",
justifyContent: "center",
alignItems: "center",
borderRadius: 10,
paddingHorizontal: 5,
paddingVertical: 2,
},
action_buttons_text: {
color: '#fff',
fontSize: 16,
padding: 5
},
bottomLogoContainer:{
alignSelf: "center",
justifyContent: 'center',
alignItems: 'center',
textAlign:"center",
height: 100,
marginBottom: 20,
zIndex: 0
},
bottomLogoImage:{
width: 150,
height: 150,
resizeMode: 'contain',
}
});
if (this.state.loading) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<ActivityIndicator />
</View>
)
}
return (
<>
<StatusBar barStyle="light-content" />
<SafeAreaView style={styles.container}>
<FlatList
data={DATA}
keyExtractor = {(item, index) => index.toString()}
renderItem={({ item }) => (
<Card style={styles.menuContainer}>
{/* <Card.Cover source={{ uri: item.cover_img }} /> */}
<Card.Title title={item.title.toString()} subtitle={item.title.toString()} style={styles.menuItemHeader}/>
<Card.Content style={styles.menuItemBody}>
<Paragraph style = {styles.description_input}>
<View>
<TextInput
underlineColorAndroid = "transparent"
placeholderTextColor = "gray"
autoCapitalize = "none"
multiline={true}
// numberOfLines={4}
placeholder = "Job description"
// onBlur={()=>this.lastNameValidation()}
// onChangeText={last_name => this.setState({ last_name })}
/>
</View>
</Paragraph>
<Paragraph style={styles.action_buttons_positioning}>
<TouchableOpacity onPress={() => alert('Clicked')}>
<View style={styles.action_buttons}>
<Text style={styles.action_buttons_text}>Edit</Text>
</View>
</TouchableOpacity>
</Paragraph>
</Card.Content>
</Card>
)
}
/>
{/* <View style={styles.bottomLogoContainer}>
<Image
style={styles.bottomLogoImage}
source={require('../../../../src/assets/img/logo_120.png')}
/>
</View> */}
</SafeAreaView>
</>
)
}
}
You can add paddingHorizontal: 0 in your menuItemBody styles object, i.e. the styles that apply to the Card.Content component.
The CardContent component apparently sets 16 horizontal padding by default.

NativeBase FAB is not working in React Native

First of all excuse me for asking a question which may or may not been answered before. I could not find the right answer for me.
I try to add a FAB in a react native project. Clicking on it to expand is working, but the items below it are not clickable. Neither on iOS as on Android.
I use this code:
import {useNavigation} from '#react-navigation/native';
import {Button, Fab, Icon, View} from 'native-base';
import React, {useEffect, useState} from 'react';
import {Image, Platform, SafeAreaView, StyleSheet} from 'react-native';
import {red} from '../../Settings/Theme';
const Header = () => {
const [fabActive, setFabActive] = useState(false);
const navigation = useNavigation();
useEffect(() => {
setFabActive(false);
}, []);
return (
<SafeAreaView style={styles.container}>
<View style={{flex: 1, alignItems: 'center'}}>
<Icon name="home" type="FontAwesome5" style={styles.iconStyle} />
</View>
<View style={{flex: 1, alignItems: 'center'}}>
<Image
style={styles.logoStyle}
source={{
uri: `urltologo`,
}}
/>
</View>
<View style={{flex: 1}}>
<Fab
active={fabActive}
direction="down"
containerStyle={{
marginTop: 24,
marginRight: 15,
}}
style={{
backgroundColor: red,
height: 63,
width: 63,
borderRadius: 32.5,
shadowOffset: {height: 0, width: 0},
shadowOpacity: 0,
elevation: 0,
}}
position="topRight"
onPress={() => setFabActive(!fabActive)}>
<Icon
name={fabActive ? 'times' : 'plus'}
type="FontAwesome5"
style={{fontSize: 28}}
/>
{fabActive ? (
<Button
style={{
backgroundColor: red,
height: 48,
width: 48,
borderRadius: 24,
}}
onPress={() => {
setFabActive(false);
navigation.navigate('Contact');
}}>
<Icon name="newspaper" type="FontAwesome5" />
</Button>
) : null}
{fabActive ? (
<Button
style={{
marginTop: 10,
backgroundColor: red,
height: 48,
width: 48,
borderRadius: 24,
}}>
<Icon name="lightbulb" type="FontAwesome5" />
</Button>
) : null}
{fabActive ? (
<Button
style={{
marginTop: 20,
backgroundColor: red,
height: 48,
width: 48,
borderRadius: 24,
}}>
<Icon name="calendar-week" type="FontAwesome5" />
</Button>
) : null}
{fabActive ? (
<Button
style={{
marginTop: 30,
backgroundColor: red,
height: 48,
width: 48,
borderRadius: 24,
}}>
<Icon name="list" type="FontAwesome5" />
</Button>
) : null}
</Fab>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
paddingTop: Platform.OS === 'android' ? 30 : 0,
backgroundColor: 'transparent',
flex: 1,
flexDirection: 'row',
justifyContent: 'space-evenly',
},
iconStyle: {
marginTop: 40,
color: 'white',
fontSize: 32,
backgroundColor: red,
padding: 15,
borderWidth: 0,
overflow: 'hidden',
borderRadius: 32,
},
logoStyle: {
height: 135,
width: 135,
resizeMode: 'contain',
},
});
export default Header;
And I import it like this:
import React from "react";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
import BackImage from "../Components/Common/BackgroundImage";
import HeaderComponent from "../Components/Common/Header";
import NewsComponent from "../Components/NewsComponent";
const NewsScreen = ({ navigation }) => {
return (
<BackImage>
<HeaderComponent />
<View style={styles.container}>
<NewsComponent />
</View>
</BackImage>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default NewsScreen;
Any ideas what i do wrong here?
I found your problem.
container: {
paddingTop: Platform.OS === 'android' ? 30 : 0,
backgroundColor: 'transparent',
flex: 0.2,
flexDirection: 'row',
justifyContent: 'space-evenly',
},
Change flex: 0.2 to flex: 1,

React-native TouchableOpacity button doesn't respect border/border-radius

I have created a generic button which I'd like to have round edges instead of being a square. My button component is as such:
const Button = ({ onPress, children }) => {
const { buttonStyle, textStyle } = styles;
return (
<TouchableOpacity onPress={onPress} style={buttonStyle}>
<Text style={textStyle}>
{children}
</Text>
</TouchableOpacity>
);
};
const styles = {
textStyle: {
alignSelf: 'center',
color: colors.primaryTeal,
fontSize: 16,
fontWeight: '600',
paddingTop: 10,
paddingBottom: 10,
},
buttonStyle: {
flex: 1,
backgroundColor: colors.whiteText,
marginLeft: 5,
marginRight: 5,
borderRadius: 50
}
};
However, it remains to be square and doesn't respond to borderRadius at all.
It's invoked as such:
<Button onPress={this.onButtonPress.bind(this)}>
Log in
</Button>
How do I make it respect borderRadius and get round edges?
The login form in which it appears(Render)
render() {
return (
<Card>
<CardSection>
<Input
placeholder="user#gmail.com"
label="Email"
value={this.state.email}
onChangeText={email => this.setState({ email })}
/>
</CardSection>
<CardSection>
<Input
secureTextEntry
placeholder="password"
label="Password"
value={this.state.password}
onChangeText={password => this.setState({ password })}
/>
</CardSection>
<View style={styles.btnWrapper}>
<CardSection>
{this.state.loading ?
<Spinner size="small" /> :
<Button onPress={this.onButtonPress.bind(this)}>
Log in
</Button>}
</CardSection>
</View>
<Text style={styles.errorTextStyle} disabled={this.state.error !== null}>
{this.state.error}
</Text>
</Card>
CardSection component:
const CardSection = (props) => {
return (
<View style={styles.containerStyle}>
{props.children}
</View>
);
};
const styles = {
containerStyle: {
borderBottomWidth: 1,
padding: 5,
backgroundColor: '#fff',
justifyContent: 'flex-start',
flexDirection: 'row',
borderColor: '#ddd',
position: 'relative'
}
};
Works perfectly fine. Just make sure to use react native's StyleSheet.create to get cached styles.
Maybe your button container view background is white and you're not seeing the rounded corners.
Heres my working snack
Code snippet i used, but refer to the snack as you'll see it live in action.
import React, { Component } from 'react';
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native';
const Button = ({ onPress, children }) => {
return (
<TouchableOpacity onPress={onPress} style={styles.buttonStyle}>
<Text style={styles.textStyle}>
{children}
</Text>
</TouchableOpacity>
);
};
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Button>
Log in
</Button>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex:1,
backgroundColor: 'black',
},
textStyle: {
alignSelf: 'center',
color: 'teal',
fontSize: 16,
fontWeight: '600',
paddingTop: 10,
paddingBottom: 10,
},
buttonStyle: {
flex: 1,
backgroundColor: 'white',
marginLeft: 5,
marginRight: 5,
borderRadius: 50
},
});
You have to add style overflow: hidden to TouchableOpacity
Try add attribute borderWidth and borderColor on buttonStyle, like below:
buttonStyle: {
backgroundColor: colors.whiteText,
marginLeft: 5,
marginRight: 5,
borderRadius: 50,
borderWidth: 2,
borderColor: "#3b5998"
}
A complete example:
<TouchableOpacity
onPress={() => handleSubmit()}
disabled={!isValid}
style={{
alignSelf: "center",
marginBottom: 30,
overflow: 'hidden',
borderColor: "#3b5998",
borderWidth: 2,
borderRadius: 100,
}}
>
<View
style={{
flexDirection: "row",
alignSelf: "center",
paddingLeft: 15,
paddingRight: 15,
minHeight: 40,
alignItems: 'center',
}}
>
<Text style={{ fontSize: 20, fontWeight: "bold", color: "#3b5998" }}>
SEND
</Text>
</View>
</TouchableOpacity>
I think you might be looking for the containerStyle prop
<TouchableOpacity containerStyle={ViewStyleProps}>