右上角的位置反应原生

Sto*_*ace 4 javascript styles stylesheet react-native

父级component具有以下样式

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

component在这个组件中放置另一个.我希望它在右上角.

当然,我会在这个孩子中使用以下风格component:

const styles = StyleSheet.create({
  container: {
    ...StyleSheet.absoluteFillObject,
    top: 20,
    right: 5,
  },
});
Run Code Online (Sandbox Code Playgroud)

然而,它把它在顶部左侧角落.我可以把它移动到右上角的唯一方法是更换right: 5left: 500.但那不是那种方式......

Jig*_*hah 7

请检查下面的子组件样式表:

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