同样的样式,为啥我写出来的比老师写出来的卡号看起来更靠底?
来源:7-5 ImageBackground-View和Image的结合

佚__名
2023-04-11
我写的
完整代码:
import React, {useRef} from 'react';
import {StyleSheet, ImageBackground, View, Image, Text} from 'react-native';
import bgCard from '../assets/images/bg_card.png';
import iconBank from '../assets/images/icon_bank.png';
export default () => {
// const viewRef = useRef(null);
// const imgRef = useRef(null);
return (
<View style={styles.root}>
<ImageBackground
style={styles.viewStyle}
imageStyle={styles.imgStyle}
source={bgCard}
// ref={viewRef}
// imageRef={imgRef}
>
<Image style={styles.iconLogo} source={iconBank} />
<Text style={styles.txtBank}>
{'招商银行\n'}
<Text style={styles.txtCardType}>{'储蓄卡\n\n'}</Text>
<Text style={styles.txtCardNo}>●●●● ●●●● ●●●● 3068</Text>
</Text>
</ImageBackground>
</View>
);
};
const styles = StyleSheet.create({
root: {
width: '100%',
height: '100%',
flexDirection: 'column',
},
viewStyle: {
width: '100%',
height: 150,
flexDirection: 'row',
alignItems: 'flex-start',
},
imgStyle: {
resizeMode: 'cover',
borderRadius: 12,
},
iconLogo: {
width: 48,
height: 48,
marginLeft: 20,
marginTop: 20,
},
txtBank: {
fontSize: 24,
color: 'white',
marginLeft: 10,
marginTop: 21,
fontWeight: 'bold',
},
txtCardType: {
fontSize: 20,
color: '#FFFFFFA0',
fontWeight: 'normal',
},
txtCardNo: {
fontSize: 26,
color: 'white',
},
});
写回答
2回答
-
vscode
2024-12-17
应该是那个\n换行引起的吧,感觉换行处理那个距离不太好,
00 -
FE大公爵
2023-04-12
布局的优化有时候需要不断的调整,一种布局方式如果在不同尺寸或者像素密度的手机里显示效果不统一,那就可能要换一种布局方式,让布局更有弹性。这课程在前期没有特别讲布局的弹性,在后面的实战中布局优化会显得更重要。
00
相似问题