how to properly style image in react native - reactjs

I've just started learning React Native.. this is what my current app looks like
this is my code so far:
import { StatusBar } from 'expo-status-bar';
import { SafeAreaView, StyleSheet, Text, Image, View, Button, TextInput } from 'react-native';
export default function App() {
return (
<SafeAreaView style={styles.container}>
<View style={styles.mainContainer}>
<View style={styles.logoContainer}>
<Image style={styles.logoImage} source={require("./assets/logo03t.png")} />
</View>
<Text style={styles.logoText}>App untuk Edy Kiatmadja ver 1.0</Text>
<TextInput style={styles.input} placeholder="Username" />
<TextInput style={styles.input} placeholder="Password" />
</View>
<StatusBar style="auto" />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'dodgerblue',
alignItems: 'center',
justifyContent: 'center',
},
logoContainer: {
padding: 20,
},
logoImage: {
resizeMode: 'contain',
height: 200,
backgroundColor: "#fff",
},
logoText: {
marginTop: 8,
fontSize: 12,
fontStyle: 'italic',
},
mainContainer: {
flex: 1,
justifyContent: 'center', // horizontal axis
alignItems: 'center', // vertical axis
},
input: {
height: 40,
margin: 10,
borderWidth: 1,
padding: 10,
width: 200,
}
});
what do I have to do to make the Image not cut-off?

Set a maximum width of current screen width in logoContainer style. You can use react-native's Dimension API to find current device width & height.
To get the device width:
import { Dimensions } from 'react-native';
const windowWidth = Dimensions.get('window').width;
Then use this as width of the container.
...
logoContainer: {
padding: 20,
maxWidth: windowWidth,
},
...

Related

Animated Header with ScrollView is not working

this is my profile page I want scroll animation but I didn't get output
** there is two-part one is header and body part is fully based on card view **
import React, { useRef } from 'react';
import {
StyleSheet,
Text,
View,
Image,
Animated,ScrollView
} from 'react-native';
import { TouchableOpacity } from 'react-native-gesture-handler';
import {Card, Title, Paragraph } from 'react-native-paper';
import { MaterialCommunityIcons } from '#expo/vector-icons';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import SafeAreaView from 'react-native-safe-area-view';
import AnimatedHeader from 'C:\Users\keerthana\Desktop\mobile-client-1\src\components\AnimatedHeader.js';
const SettingsScreen=()=>{
const offset = useRef(new Animated.Value(0)).current;
return ( <SafeAreaProvider>
<SafeAreaView style={{ flex: 1 }} forceInset={{ top: 'always' }}>
<AnimatedHeader animatedValue={offset} />
<ScrollView
style={{ flex: 1, backgroundColor: 'white' }}
contentContainerStyle={{
alignItems: 'center',
paddingTop: 220,
paddingHorizontal: 20
}}
showsVerticalScrollIndicator={false}
scrollEventThrottle={16}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: offset } } }],
{ useNativeDriver: false }
)}
>
<View style={styles.header}>
<View style={styles.headerContent}>
<Image style={styles.avatar} source={{uri: 'https://bootdey.com/img/Content/avatar/avatar2.png'}}/>
<Text style={styles.name}>
Name
</Text>
</View>
<View style={{ backgroundColor: "#FFF"}}>
<Card style={{padding:5,borderWidth: 1,borderRadius: 1,borderColor: '#adacac',marginTop:20}}>
<Card.Title title="INFO" subtitle="username" />
<Card.Content>
<Title style={{fontSize:16}}>Phone Number</Title>
<Paragraph>0000000000000</Paragraph>
</Card.Content>
<Card.Content style={{borderWidth: 0, borderColor: 'transparent', elevation: 0}}>
<Title style={{fontSize:16}}>Slogan</Title>
<Paragraph >Testing leads to failure, and failure leads to understanding</Paragraph>
</Card.Content>
</Card>
<Card style={{padding:5,borderWidth: 1,borderRadius: 1,borderColor: '#adacac',marginTop:10}}>
<Card.Title title="Groups" />
</Card>
<View style={{padding:5,borderWidth: 1,borderRadius: 1,borderColor: '#adacac',marginTop:10}}>
//group
<TouchableOpacity>
<View style={{flex: 1,justifyContent: 'center',marginLeft:20}}>
<Image
width={450}
containerStyle={{flex: 0.37}}
imageProps={{resizeMode:'cover'}}
source={{uri: 'https://bootdey.com/img/Content/avatar/avatar2.png'}}
activeOpacity={0.7}
/>
</View>
<View style={{flex: 11,flexDirection: 'column',justifyContent: 'center'}}>
<View style={{ flexDirection: 'row',justifyContent: 'flex-start', marginLeft: 9 }}>
<Text >music game</Text>
</View></View>
</TouchableOpacity>
<TouchableOpacity>
<Text>ludo game</Text>
</TouchableOpacity>
<TouchableOpacity>
<Text> game</Text>
</TouchableOpacity>
</View>
</View>
</View>
</ScrollView>
</SafeAreaView>
</SafeAreaProvider>
);
};
export default SettingsScreen;
const styles=StyleSheet.create({
header:{
backgroundColor: "#e6e3e3",
},
headerContent:{
padding:30,
alignItems: 'center',
},
avatar: {
width: 130,
height: 130,
borderRadius: 63,
borderWidth: 4,
borderColor: "white",
marginBottom:10,
},
name:{
fontSize:22,
color:"#FFFFFF",
fontWeight:'600',
},
profileDetail:{
alignSelf: 'center',
marginTop:200,
alignItems: 'center',
flexDirection: 'row',
position:'absolute',
backgroundColor: "#ffffff"
},
detailContent:{
margin:10,
alignItems: 'center'
},
title:{
fontSize:20,
color: "#00CED1"
},
count:{
fontSize:18,
},
bodyContent: {
flex: 1,
alignItems: 'center',
padding:30,
marginTop:40
},
textInfo:{
fontSize:18,
marginTop:20,
color: "#696969",
},
buttonContainer: {
marginTop:10,
height:45,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom:20,
width:250,
borderRadius:30,
backgroundColor: "#00CED1",
},
description:{
fontSize:20,
color: "#00CED1",
marginTop:10,
textAlign: 'center'
},
});
animation page
** this animation is used for profile page scroll **
import React from 'react';
import {
Animated,
TouchableOpacity,
View,
Text,
StyleSheet
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const HEADER_HEIGHT = 200;
const AnimatedHeader = ({ animatedValue }) => {
const insets = useSafeAreaInsets();
const headerHeight = animatedValue.interpolate({
inputRange: [0, HEADER_HEIGHT + insets.top],
outputRange: [HEADER_HEIGHT + insets.top, insets.top + 44],
extrapolate: 'clamp'
});
return (
<Animated.View
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
zIndex: 10,
height: headerHeight,
backgroundColor: 'lightblue'
}}
/>
);
};
export default AnimatedHeader;
without using the animation part its works properly but after adding animation I don't know why it's not working.

How to move down a object using button in react native?

Actually I want to do something like that (Image attached):
There have a box, and two buttons. If I press button 1 then the box moved left. And if I press button 2 then the box moved right.
I want, when the box move right and overcome the bar 1 then the box moved down on the bar 2.
But I have no idea how to do it.
Here is my code:
import React, {Component} from 'react';
import {
View,
Text,
StyleSheet,
Animated,
TouchableOpacity,
ScrollView,
Image,
} from 'react-native';
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
left: 20,
};
}
moveRight = () => {
this.setState({left: this.state.left + 10}); // 10 is value of change.
};
moveLeft = () => {
this.setState({left: this.state.left - 10}); // 10 is value of change.
};
render() {
return (
<View style={styles.container}>
<Image
style={{left: this.state.left, height: 120, width: 120}}
source={require('./assets/box.png')}
/>
<Image
style={{height: 20, width: 180, marginTop: -12, marginLeft: 25}}
source={require('./assets/log.png')}
/>
<Image
style={{height: 20, width: 200, marginTop: 150, marginLeft: 185}}
source={require('./assets/log.png')}
/>
<View style={styles.buttonsContainer}>
<TouchableOpacity onPress={this.moveLeft}>
<Image
style={{height: 60, width: 60}}
source={require('./assets/left-button.png')}
/>
</TouchableOpacity>
<TouchableOpacity onPress={this.moveRight}>
<Image
style={{height: 60, width: 60}}
source={require('./assets/right-button.png')}
/>
</TouchableOpacity>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
textCenter: {
alignSelf: 'center',
textAlign: 'center',
},
levelHeading: {
fontWeight: 'bold',
fontSize: 35,
color: '#CC8A4F',
},
buttonsContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 200,
paddingLeft: 80,
paddingRight: 80,
},
});
Please help me!
Thanks!
import React, { useEffect } from "react";
import { Animated, Text, View, StyleSheet, Button } from "react-native";
const App = () => {
const moveAnimation = new Animated.ValueXY({ x: 10, y: 450 });
useEffect(() => {
moveAnimation;
}, []);
const _moveBallLeft = () => {
Animated.spring(moveAnimation, {
toValue: { x: 250, y: 450 },
}).start();
};
const _moveBallRight = () => {
Animated.spring(moveAnimation, {
toValue: { x: 10, y: 450 },
}).start();
};
return (
<View style={styles.container}>
<Animated.View style={[styles.tennisBall, moveAnimation.getLayout()]}>
<View style={styles.button}>
<Text style={styles.buttonText}>ball</Text>
</View>
</Animated.View>
<View
style={{
flexDirection: "row-reverse",
justifyContent: "space-evenly",
}}
>
<View style={{ alignSelf: "center" }}>
<Button title=">" onPress={_moveBallLeft}></Button>
</View>
<View style={{ alignSelf: "center", marginLeft: "2%" }}>
<Button title="<" onPress={_moveBallRight}></Button>
</View>
</View>
</View>
);
};
export default App;
const styles = StyleSheet.create({
container: {
flex: 2,
backgroundColor: "#ecf0f1",
},
tennisBall: {
display: "flex",
justifyContent: "center",
alignItems: "center",
backgroundColor: "greenyellow",
borderRadius: 100,
width: 100,
height: 100,
},
button: {
paddingTop: 24,
paddingBottom: 24,
},
buttonText: {
fontSize: 24,
color: "#333",
},
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

My React native app is going back to splash screen whenever i press a button with navigation function

I have made a splash screen by just placing an image and a setInterval() function, after that interval i have added the statement to navigate to login screen(navigation.navigate('loginScreen'), on login screen on a button(Signup button) i have added the fonPress() to navigate to signup screen(navigation.navigate('SignupScreen'). it works and the app goes to signup screen but the same setinterval function runs again and screen automatically navigates to login page again.
///////////////////////// App.js /////////////////////////////////
import 'react-native-gesture-handler';
import React from 'react';
import SplashScreen from './app/screens/splash.screen';
import LoginScreen from './app/screens/login.screen';
import SignupScreen from './app/screens/signup.screen';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Image,
ImageBackground,
} from 'react-native';
import { NavigationContainer } from '#react-navigation/native';
import { createStackNavigator } from '#react-navigation/stack';
import { Header } from 'react-native/Libraries/NewAppScreen';
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="SplashScreen" headerMode='none' >
<Stack.Screen name="SplashScreen" component={SplashScreen} />
<Stack.Screen name="LoginScreen" component={LoginScreen} />
<Stack.Screen name="SignupScreen" component={SignupScreen}/>
</Stack.Navigator>
</NavigationContainer>
);
};
const styles = StyleSheet.create({
});
export default App;
//////////////////////splash screen code///////////////////
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Image,
ImageBackground,
Button,
} from 'react-native';
function SplashScreen({ navigation }) {
//method to give splash screen effect ,screen navigates to next screen after 9000 milliseconds
setInterval(() => { navigation.navigate('LoginScreen')}, 9000);}
return (
<View style={styles.bod} >
<Text>{kaka}</Text>
<Image source={require("../../Images/ss1.jpg")} style={{flex:1,width:null, height: null}}/>
</View>
);
}
// const SplashScreen = () => {
// return (
// <View style={styles.bod}>
// <Image source={require("../../Images/ss1.jpg")} style={{width: '100%', height: '100%'}}/>
// <Button
// title="Go to Details"
// onPress={() => navigation.navigate('LoginScreen')}
// />
// </View>
// );
// };
const styles = StyleSheet.create({
bod : {
flex:1,
},
img:{
}
});
export default SplashScreen;
///////////Login Screen code//////////////////////
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
Image,
ImageBackground,
Button,
} from 'react-native';
import { greaterThan } from 'react-native-reanimated';
import { TextInput } from 'react-native-gesture-handler';
function LoginScreen({ navigation }) {
return (
<View style={styles.grandparent}>
<View style={styles.welcom} >
<Text style={{color:'white',fontSize:35,fontFamily: "sans-serif-thin"}}>Welcome to CAWN!</Text>
</View>
<View style={styles.logo}>
<Image source={require("../../Images/logo2.png")} style={{width:'100%',height:'100%'}}/>
</View>
<View style={styles.mainlogin}>
<View style={styles.loginChild1}>
<Text style={{color:'white',fontSize:28,fontFamily:"sans-serif",paddingTop:4,}}>Member Sign In!</Text>
{/* <Image source={require("../../Images/user.png")} style={{width:'100%',height:'100%'}}/> */}
</View>
<View style={styles.fieldsMain}>
<View style={styles.userDiv}>
<View style={{flex: 1.5,width: 100,height: 53}}>
<Image source={require("../../Images/user.png")} style={{width:'100%',height:'100%'}}/>
</View>
<View style={{ flex: 5, width: 100,paddingLeft:4,}}>
<TextInput style={{ height: 48,backgroundColor:'white' }}></TextInput>
</View>
</View>
<View style={styles.psDiv}>
<View style={{flex: 1.5,width: 100,height: 53}}>
<Image source={require("../../Images/password1.png")} style={{width:'100%',height:'100%'}}/>
</View>
<View style={{ flex: 5, width: 100,paddingLeft:4,}}>
<TextInput style={{ height: 48,backgroundColor:'white', }}></TextInput>
</View>
</View>
<View style={{flex:0.3,}}></View>
</View>
<View style={styles.loginLastRow}>
<View style={styles.loginLastRowChild1}>
<Button title="Log in" color="#31b9eb" onPress={() => Alert.alert('Simple Button pressed')} />
</View>
<View style={styles.loginLastRowChild2}>
<View style={{paddingBottom:4,}}>
<Text style={{color:'white',fontSize:25,fontFamily: "sans-serif-thin",}}>Not a Member yet?</Text>
</View>
<Button title="Sign Up" color="#31b9eb" onPress={() => navigation.navigate('SignupScreen')} />
</View>
</View>
</View>
<View style={styles.lastSpace} />
</View>
);
}
const styles = StyleSheet.create({
grandparent : {
flex: 1,
width: '100%',
height: '100%',
justifyContent: 'center',
alignItems: 'center',
alignContent: 'center',
paddingHorizontal: 20,
paddingBottom: 30,
flexWrap: 'wrap',
//added by MFU
paddingTop:10,
backgroundColor:'#c3c8ed',
// borderWidth:1,
// borderColor:'red',
},
welcom : {
flex: 0.6,
width: '100%',
height: 100,
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
alignContent: 'center',
// added by mfu
// borderWidth:1,
// borderColor:'green',
},
logo : {
flex: 1.9,
width: 250,
height: 100,
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
alignContent: 'center',
// added by mfu
paddingTop:6,
// borderWidth:1,
// borderColor:'blue',
},
mainlogin : {
flex: 3.5,
width: 300,
height: 150,
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
alignContent: 'center',
// borderWidth:3,
// borderColor:'black',
},
loginChild1 : {
flex: 0.4,
width: '100%',
height: 100,
flexWrap: 'wrap',
//added by MFU
alignItems: 'center',
alignContent: 'center',
// borderWidth:1,
// borderColor:'red',
},
fieldsMain : {
flex: 1.2,
width: '100%',
height: 100,
//added by mfu
alignItems: 'center',
// borderWidth:1,
// borderColor:'blue',
},
userDiv : {
flex: 1,
width: '80%',
// height: '100%',
//added by mfu
// borderWidth:1,
// borderColor:'green',
flexDirection: 'row',
},
psDiv : {
flex: 1,
width: '80%',
// height: 100,
//added by mfu
// borderWidth:1,
// borderColor:'pink',
flexDirection: 'row',
},
loginLastRow : {
flex: 1,
width: '80%',
height: 100,
//added by mfu
// borderWidth:1,
// borderColor:'purple',
},
loginLastRowChild1 : {
flex: 1,
width: 100,
height: 100,
// borderWidth:1,
// borderColor:'red',
},
loginLastRowChild2 : {
flex: 1,
width: '100%',
height: 100,
// borderWidth:1,
// borderColor:'green',
},
lastSpace : {
flex: 0.5,
width: 250,
height: 100,
// borderWidth:1,
// borderColor:'green',
},
});
export default LoginScreen;
setInterval runs the code repeatedly at the interval provided. I think you might want setTimeout (which will run just once)

React native: change button size in center screen

I am new to React Native currently learning about the technology.
I start create a card layout with buttons inside it.
This is my layout :
<KeyboardAvoidingView
behavior='padding'
keyboardVerticalOffset={50}
style={styles.screen}>
<LinearGradient
colors={['#ffedff', '#ffe3ff']}
style={styles.gradient}>
<Card style={styles.card}>
<ScrollView>
<View style={styles.buttonContainer}>
<Button
color={Colors.primary}
title='ورود'
onPress={() => { }} />
</View>
</ScrollView>
</Card>
</LinearGradient>
</KeyboardAvoidingView>
and this is my stylesheet :
const styles = StyleSheet.create({
screen: {
flex: 1
},
gradient: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
card: {
width: '90%',
height: '80%',
padding: 20
},
buttonContainer: {
alignItems: 'center',
marginVertical: 30,
},
});
and result is:
I want to make button bigger so i added width to buttonContainer but button changed position to left of screen and its size does not change.
buttonContainer: {
width: '40%',
alignItems: 'center',
marginVertical: 30,
},
How could i change button width when it is in the center of screen?
So basically alignSelf:'center' was the problem. Removing that worked. Check the expo link below and the code :
import React from 'react';
import {
StyleSheet,
Text,
View,
TextInput,
KeyboardAvoidingView,
ScrollView,
Button
} from 'react-native';
import { LinearGradient } from 'expo-linear-gradient'
import Card from './Card';
export default AuthScreen = () => {
return (
<KeyboardAvoidingView
behavior='padding'
keyboardVerticalOffset={50}
style={styles.screen}>
<LinearGradient
colors={['#ffedff', '#ffe3ff']}
style={styles.gradient}>
<Card style={styles.card}>
<ScrollView>
{/* <View style={styles.wcContainer}>
<Text style={styles.headerText}>خوش آمدید</Text>
</View> */}
{/* <View style={styles.container}>
<Text style={styles.text}>نام کاربری</Text>
<TextInput style={styles.input} />
<Text style={styles.text}>رمز عبور</Text>
<TextInput style={styles.input} />
</View> */}
<View style={styles.buttonContainer}>
<Button
color= 'red'
title='ورود'
style={{marginHorizontal:200}}
onPress={() => { }} />
</View>
</ScrollView>
</Card>
</LinearGradient>
</KeyboardAvoidingView>
);
}
const styles = StyleSheet.create({
screen: {
flex: 1
},
gradient: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
card: {
width: '90%',
height: '80%',
padding: 20
},
buttonContainer: {
// marginHorizontal:200,
width:'100%',
// alignItems: 'center',
// marginVertical: 30,
justifyContent:'center'
},
});
expo link : expo link
hope it helps. feel free for doubts
I fixed this problem with :
buttonContainer: {
width: '40%',
alignSelf: 'center',
marginVertical: 30,
}
Now this is my layout:

React Native (android) , components overlapping with shadow issue

I am using a custom component with image and text. The image is relative to the text. Please see the screenshot.
image 1
image 2.
I have used the TouchableOpacity component as root view for that.
In screenshots when long press on the component, two views are overlapping with shadow. It looks ugly when long press.
Please see the code below for reusable component.
'use strict';
import React, {Component} from 'react';
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Image,
} from 'react-native';
export default class ExampleButton extends Component {
constructor (props) {
super (props);
}
_handleOnPress = () => {
console.log('pressed!!!');
};
render () {
console.log (this.props);
return (
<TouchableOpacity
onPress={this.handleOnPress}
>
<View style={styles.btnCompContainer}>
<View
style={{
backgroundColor: '#FFF',
justifyContent: 'center',
borderRadius: 30,
height: 50,
width: '100%',
}}
>
<Text style={styles.btnTxt}>{this.props.buttonText}</Text>
</View>
<View style={[styles.btnElmContainer]}>
<Image
style={[{height: 30, width: 30,resizeMode:'stretch'}]}
source={this.props.image}
/>
</View>
</View>
</TouchableOpacity>
);
}
}
const styles = StyleSheet.create ({
btnCompContainer: {
flexDirection: 'row',
alignItems: 'center',
height: 60,
marginLeft: 10,
marginRight: 20,
},
btnElmContainer: {
position: 'absolute',
justifyContent: 'center',
alignItems: 'center',
width: 60,
height: 60,
backgroundColor:'#fff',
borderRadius: 30,
shadowColor: '#000000',
shadowOffset: {
width: 1,
height: 1,
},
elevation:5,
shadowRadius: 2,
shadowOpacity: 0.3,
},
btnTxt: {
marginLeft: 80,
color: '#9e9e9e',
fontSize: 16,
fontWeight: 'bold',
textAlign: 'left',
},
});
Here I am using this reusable component in code.
'use strict';
import React, {Component} from 'react';
import {
Animated,
StyleSheet,
Text,
TextInput,
View,
Image,
ImageBackground,
TouchableOpacity,
Button,
StatusBar,
Easing
} from 'react-native';
// Custom Components
const searchBGImg = require('../assets/search-bg-kit.png');
const houseLogo = require('../Resources/house.png');
import ExampleButton from './components/common/example-button';
export default class TypeSelect extends Component<Props> {
// Navigation Option
static navigationOptions = {
header: null
}
constructor() {
super();
this.state = {
visible: false,
x: new Animated.Value(-100),
};
}
slide = () => {
Animated.spring(this.state.x, {
toValue: 0,
easing: Easing.easeOutBack
}).start();
this.setState({
visible: true,
});
};
gotoSearch = () =>{
this.props.navigation.navigate('DocSearch')
}
componentDidMount(){
this.slide();
}
render() {
return (
<View style={styles.container}>
<ImageBackground source={searchBGImg} style={styles.imgBG}>
<View style={{alignItems:'center', marginBottom:20}}>
<Image style={{height:57, width:69, marginBottom:12}} source={houseLogo} />
</View>
<View>
<Animated.View
style={[styles.slideView, {
transform: [
{
translateX: this.state.x
}
]
}]}>
<ExampleButton image={houseLogo} buttonText={'Click here'} />
<ExampleButton image={houseLogo} buttonText={'Click here'} />
</Animated.View>
</View>
</ImageBackground>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1
},
imgBG:{
flex: 1,
flexDirection: "column",
justifyContent:"center",
width: "100%",
height: "100%"
}
})
It is working fine in iOS, but it's not working in android up to the mark. Please help me to work it in android.
Thanks in advance.
You should use renderToHardwareTextureAndroid prop on <View /> component.
In your example like this:
<View style={styles.btnCompContainer} renderToHardwareTextureAndroid >
<View
style={{
backgroundColor: '#FFF',
justifyContent: 'center',
borderRadius: 30,
height: 50,
width: '100%',
}}
>
<Text style={styles.btnTxt}>{this.props.buttonText}</Text>
</View>
<View style={[styles.btnElmContainer]}>
<Image
style={[{height: 30, width: 30,resizeMode:'stretch'}]}
source={this.props.image}
/>
</View>
</View>

Resources