如何在React-Native图像组件的右下角定位子视图?

Ben*_*Ben 18 layout image react-native

我正在使用React-Native开发一个应用程序.我想在图像组件的右下角放置一个图标,但它始终位于左上角.

有帮助吗?非常感谢你.

Ras*_*yer 24

<Image source={imageSource} style={{position: "absolute", bottom: 0, right: 0}}/>
Run Code Online (Sandbox Code Playgroud)


jmu*_*rzy 22

你可以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>
);
Run Code Online (Sandbox Code Playgroud)