- Create Components folder under src folder
- Add TouchableOpacitywithImage.js file and add below Code
import React from "react";
import { TouchableOpacity, View, Text, Image } from "react-native";
const callFun = () => {
alert("Clicked on Touchable Opacity with Image Button!!!");
};
let Image_Http_URL = {
uri:
"https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgACm31aFPgZwjcGKe50tWTegyxzgNfYG94Jp2ZO48mE6RKXEFNZnkyODDqiEuGq8fevZe8oZn5gmDR_vQNmsKQ0nZ5y_ipkkRyZ203gpMXYv1hqTTxataPt5JWKuVM4w9GBMCQHOkGZV4/s1600/logo.png"
};
const TouchableOpacitywithImage = () => {
return (
<View>
<Text> TouchableOpacity with Image example</Text>
<TouchableOpacity onPress={callFun}>
<Image
style={{ height: 200, width: 350, resizeMode: "stretch" }}
source={Image_Http_URL}
/>
</TouchableOpacity>
</View>
);
};
export default TouchableOpacitywithImage;
- Open App.js file and update code as below
import React from 'react';
import { View,StyleSheet } from 'react-native';
import TouchableOpacitywithImage from './src/Component/TouchableOpacitywithImage'
const App=()=> {
return (
<View style={styles.container}>
<TouchableOpacitywithImage/>
</View>
);
}
export default App;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
paddingTop:80
},
});
No comments:
Post a Comment