0

我想将按钮浮动到地图的右侧。不知何故,它不起作用。有人可以帮忙吗?

const styles = StyleSheet.create({
  mapContainer: {
    flex: 1,
  },
  map: {
    flexDirection: 'row',
    flex: 1,
    borderRadius: 4,
    borderWidth: 2,
    borderColor: 'purple',
    width,
    height,
  },
  button: {
    marginLeft: 'auto',
    borderRadius: 4,
    borderWidth: 2,
    borderColor: 'red',
  }
})
4

2 回答 2

1

请尝试为您的按钮使用“alignSelf”布局道具,如下所示:

button: {
   alignSelf: 'flex-end',
   borderRadius: 4,
   borderWidth: 2,
   borderColor: 'red'
}
于 2018-07-03T13:26:14.570 回答
0

您可以使用这样的绝对位置:

  container: {
    position: "absolute",
    width: YOUR_WIDTH,
    height: YOUR_HEIGHT,
    right: 20,
  }
于 2018-07-03T12:35:31.230 回答