I'm trying to create a cropped image that fills the entire screen in my app.
Currently, my code looks like this:
https://i.stack.imgur.com/9DtAc.png
However, I want the small square of Homer eating donuts to occupy the entire screen, similar to the simulation I created:
https://i.stack.imgur.com/t3vXU.png
This is what my code currently looks like:
import * as React from 'react';
import { View, Image, StyleSheet } from 'react-native';
export default class CroppedImage extends React.Component {
render() {
return (
<View style={styles.container}>
<View style={styles.cropped}>
<Image
style={styles.image}
source={{
uri:
'https://upload.wikimedia.org/wikipedia/en/0/02/Homer_Simpson_2006.png'
}}
/>
</View>
</View>
);
}
}
const OFFSET_LEFT = 0;
const OFFSET_TOP = 0;
const IMAGE_WIDTH = 239 * 1.5;
const IMAGE_HEIGHT = 391 * 1.5;
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#6699CC'
},
bg: {
opacity: 0.25,
width: IMAGE_WIDTH,
height: IMAGE_HEIGHT
},
image: {
marginLeft: -OFFSET_LEFT,
marginTop: -OFFSET_TOP,
width: IMAGE_WIDTH,
height: IMAGE_HEIGHT
},
cropped: {
width: 150,
height: 150,
overflow: 'hidden',
position: 'absolute'
}
});
Can anyone assist me with achieving this?