如何在 React Native Mapbox GL 中放置浮动按钮

How to place a floating button in react native mapbox GL

我正在研究 React native 并使用 Mapbox GL 库来显示地图。现在我想在 Mapbox GL 视图的中心添加一个按钮。以下是我得到的。

这是代码。

      <View style={styles.container}>

        <Mapbox.MapView
          style={{flex: 1}}
          styleURL={Mapbox.StyleURL.Dark}
          zoomLevel={15}
          centerCoordinate={[79.900424, 6.867281]}
          showUserLocation={true}
          logoEnabled={false}
          rotateEnabled={false}
          attributionEnabled={false}
          animated={true}
          style={styles.container}>
        </Mapbox.MapView>

        <View style={{width:30, backgroundColor:"transparent"}}>
          <Button title="Button"></Button>
        </View>

      </View>

      const styles = StyleSheet.create({
        container: {
          flex: 1,
        }
      });

我该如何解决这个问题?

试试这个,

<View style={{width:30, backgroundColor:"transparent",position:'absolute',top:"50%",left:"50%",zIndex:10}}>
    <Button title="Button"></Button>
</View>