css - 在 React-Native 中的图像内定位图像
问题描述
我想将一个图像放置在另一个图像之上,但它不应该受到父图像“包含”参数的影响。如果我删除 resizeMode="contain" ,它工作正常,但否则,它看起来像这样:
我想要的是,将小图像放在父图像内。我实际上想将小图像放置在确切的角落。由于 resizeMode="contain" 而不是在空白处。我的代码如下所示:
<PagerView style={styles.pager} initialPage={0} showPageIndicator>
<View style={styles.picView} key={i}>
<ImageBackground
resizeMode="contain"
style={styles.pic}
source={{
uri: post.contents[i].path,
}}
>
<Image
style={{ position: "absolute", height: 100, width: 100 }}
source={{
uri: post.contents[i].path,
}}
/>
</ImageBackground>
</View>
</PagerView>
解决方案
我希望这对你有用,我也必须做类似的事情,所以我这样使用它,它对我有用。
<PagerView style={styles.pager} initialPage={0} showPageIndicator>
<View style={styles.container} key={i}>
<ImageBackground
resizeMode="contain"
style={styles.pic}
source={{
uri: post.contents[i].path,
}}
>
<View style={styles.container1}>
<Image
style={styles.image}
source={{
uri: post.contents[i].path,
}}
/>
</View>
</ImageBackground>
</View>
</PagerView>
const styles = StyleSheet.create({
container: {
flex: 1,
},
container1: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
pic: {
flex: 1,
width: '100%',
},
});
推荐阅读
- node.js - 内存不足反应本机地铁捆绑器
- authentication - asp.net webapi 2 中的 IAuthenticationFilter 和 IAuthorizationFilter 之间的区别?
- regex - 我有一个字符串“192.192”,为什么我不能使用 '(\d{1,3})\.\1' 来匹配它?
- sql - 具有交叉应用语法的先前记录
- python - 变量变为类型:Python 中的无
- powershell - 从 CSVFile 从多台计算机获取 ADComputer
- python - 如何在 Python 中添加/减去两个 ctypes.c_double
- android - Android 设备未进入深度打瞌睡
- python - Sympy无法求解方程
- javascript - 单选按钮的警报消息