代码之家  ›  专栏  ›  技术社区  ›  Wild Goat

反应本机图像缩放

  •  0
  • Wild Goat  · 技术社区  · 7 年前

    我有一个背景图像,但是在不同的屏幕大小上,它的比例不同。如果你看看脚印上的底部,很容易看出它们有多不同。我基本上希望这两个图像在所有屏幕分辨率上都相同。有没有办法解决这个问题?

    enter image description here

    import React from 'react';
    import {View, StyleSheet, Text, ImageBackground, TouchableHighlight, Image, Dimensions} from "react-native";
    import {connect} from 'react-redux';
    import EStyleSheet from 'react-native-extended-stylesheet';
    
    class SignInUpGender extends React.Component{
        render() {
            return (
                <ImageBackground style={styles.Image} source={require('../../assets/images/background_loading2.jpeg')}>
    
                </ImageBackground>
    
            )
        }
    }
    export default connect()(SignInUpGender);
    
    
    const entireScreenWidth = Dimensions.get('window').width;
    EStyleSheet.build({$rem: entireScreenWidth / 380});
    
    const styles = EStyleSheet.create({
        Image: {
            width: '100%',
            height: '100%',
        }
    });
    
    0 回复  |  直到 7 年前
        1
  •  0
  •   sarath    7 年前

    https://facebook.github.io/react-native/docs/image#resizemode

    这可能是你需要使用的道具。它也适用于ImageBackground。

    推荐文章