我在React Native中创建了自适应布局,因此我要做的就是使我的svg图像比例与屏幕尺寸成比例。如何在React Native中使用react-native-svg做到这一点?
答案 0 :(得分:1)
使用react-native-responsive-screen可以根据屏幕大小使用值,如下所示:
import {widthPercentageToDP as wp, heightPercentageToDP as hp} from 'react-native-responsive-screen';
class Login extends Component {
render() {
return (
<View style={styles.container}>
<View style={styles.textWrapper}>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: { flex: 1 },
textWrapper: {
height: hp('70%'), // 70% of height device screen
width: wp('80%') // 80% of width device screen
}
});
export default Login;