react-native-fast-image
react-native-fast-image copied to clipboard
Who can fix a copy of the wrong Android onload width and height
Who can fix a copy of the wrong Android onload width and height
Has anyone found the solution?
Who can fix a copy of the wrong Android onload width and height
workaround,
import {Platform,Image} from 'react-native';
onLoad={(event) => {
if (props.width) {
if (Platform.OS == 'android') {
if (props.source.uri) {
Image.getSize(props.source.uri, (width, height) => {
setImageInfo(adjustSize(width, height, {width: newWidth}));
});
} else {
const localInfo = Image.resolveAssetSource(source);
setImageInfo(adjustSize(localInfo.width, localInfo.height, {width: newWidth}));
}
} else {
let height = event.nativeEvent.height;
let width = event.nativeEvent.width;
setImageInfo(adjustSize(width, height, {width: newWidth}));
}
}
}}
const height = Platform.OS === 'android' ? ((e.nativeEvent?.source?.height * baseWidth) / e.nativeEvent?.source?.width) : (e.nativeEvent.height * baseWidth) / e.nativeEvent.width
const imgStyle = {
width: baseWidth,
height: height || baseWidth
};
this.setState({ imgStyle: imgStyle })