Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to position a child view on right-bottom corner of a React-Native image component?

I'm developing an app with React-Native. I want to put an icon on right-bottom corner of an image component, but it always stays on the left-top corner.

Any help? Thank you very much.

like image 351
Ben Avatar asked Apr 29 '16 07:04

Ben


People also ask

How do you position a view at the bottom of the screen React Native?

To move the button to the bottom, we use justifyContent to lay out items in the main axis, with flex-end , which aligns the flex items at the end of the container.

How do you position elements in React Native?

position in React Native is similar to regular CSS, but everything is set to relative by default, so absolute positioning is always relative to the parent. If you want to position a child using specific numbers of logical pixels relative to its parent, set the child to have absolute position.


2 Answers

<Image source={imageSource} style={{position: "absolute", bottom: 0, right: 0}}/> 
like image 139
RasTheDestroyer Avatar answered Sep 18 '22 11:09

RasTheDestroyer


You can use justifyContent: 'flex-end' to achieve this:

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>
);
like image 42
jmurzy Avatar answered Sep 17 '22 11:09

jmurzy