0

I am trying to position a View in the top right corner of the screen in my react native app and have done so using: alignSelf: 'flex-end' with position: absolute. This works, however I now want to add a margin around the box with margin: 15 but this doesn't work. The View has margin on the top but not on the right, presumably because my usage of flex-end places the View as far left as possible. How do I override this and add margin all around the View?

M. Alex
  • 673
  • 5
  • 26

1 Answers1

0

Just don't use alignSelf: 'flex-end', since you have already position: 'absolute', use top: 15 and right: 15 to have it at top right with 15 pixels distance:

<View style={{
  flex: 0,
  position: 'absolute',
  top: 15,
  right: 15
}}>...</View>
Christos Lytras
  • 36,310
  • 4
  • 80
  • 113