放置右上角反应本机

Place top right corner react native

parentcomponent有如下样式

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFF',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

我要在此组件中放置另一个 component。我想要它在 top-right 角落。

当然,我会在这个 child component:

中使用以下样式
const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    top: 20,
    right: 5,
  },
});

但是,它会将其放在 的上角。我可以将它移到右角的唯一方法是用 left: 500 替换 right: 5。但这不是要走的路...

请检查以下子组件样式表:

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    alignSelf: 'flex-end',
    marginTop: -5,
    position: 'absolute', // add if dont work with above
  }
});