【发布时间】:2016-08-24 05:20:32
【问题描述】:
我正在使用 React-Native 开发一个应用程序。 我想在图像组件的右下角放置一个图标,但它总是停留在左上角。
有什么帮助吗?非常感谢。
【问题讨论】:
标签: image layout react-native
我正在使用 React-Native 开发一个应用程序。 我想在图像组件的右下角放置一个图标,但它总是停留在左上角。
有什么帮助吗?非常感谢。
【问题讨论】:
标签: image layout react-native
<Image source={imageSource} style={{position: "absolute", bottom: 0, right: 0}}/>
【讨论】:
您可以使用justifyContent: 'flex-end' 来实现:
const withWatermark = (asset, logo) => (
<Image style={{ width: 200, height: 200, justifyContent: 'flex-end' }} source={asset}>
<Image style={{ width: 20, height: 20, alignSelf: 'flex-end' }} source={logo} />
</Image>
);
【讨论】:
你可以做这样的事情......
使用这个:position: "absolute", bottom: 0, alignSelf: "flex-end"
<ImageBackground
source={require("../assets/homeAssets/3.jpg")}
style={{
height: 140,
width: 140,
resizeMode: "contain",
alignItems: "center"
}}
imageStyle={{ borderRadius: 70 }}
>
<View
style={{
height: 50,
width: 50,
borderRadius: 25,
backgroundColor: "#99AAAB",
alignItems: "center",
justifyContent: "center",
position: "absolute", //Here is the trick
bottom: 0,
alignSelf: "flex-end"
}}
>
<Entypo name="camera" size={25} color="#FFF" />
</View>
</ImageBackground>
【讨论】: