react-native-fast-image icon indicating copy to clipboard operation
react-native-fast-image copied to clipboard

Who can fix a copy of the wrong Android onload width and height

Open afeichuanqi opened this issue 5 years ago • 3 comments

Who can fix a copy of the wrong Android onload width and height

afeichuanqi avatar Dec 22 '19 12:12 afeichuanqi

Has anyone found the solution?

sekizlipenguen avatar Mar 29 '20 14:03 sekizlipenguen

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}));
                        }
                    }
}}

sekizlipenguen avatar Mar 29 '20 17:03 sekizlipenguen


    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 })

suwu150 avatar Apr 12 '22 08:04 suwu150