繁体   English   中英

在谷歌地图android上显示按钮的问题

[英]Problem with showing button over google maps android

我在 android 中使用谷歌地图。 尝试使用谷歌地图和屏幕上的其他一些小部件(如抽屉图标)创建布局。 这是我的 xml 代码。 我面临的问题是抽屉图标在 xml 设计布局中可见,但是当我在设备上运行应用程序时它不可见。

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.home.HomeFragment">


       <com.google.android.gms.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="MissingConstraints" >
           <ImageView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_menu_orange"
               android:layout_marginTop="20dp"
               android:layout_marginLeft="20dp">
           </ImageView>
       </com.google.android.gms.maps.MapView>
</RelativeLayout>

界面设计

我使用过地图但没有使用过谷歌地图,无论如何您是否尝试过将 imageview 放在相对布局中而不是放在 MapView 中? 相对布局就是为此目的而制作的,因此项目 init 可以重叠。 不确定谷歌地图 mapview 是否会接受 Imageview

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment">


   <com.google.android.gms.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="MissingConstraints" />


   <ImageView
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:src="@drawable/ic_menu_orange"
           android:layout_margin="20dp"
           android:layout_alignParentBottom="true"
           android:layout_alignParentEnd="true">
   </ImageView>
</RelativeLayout>

另外,如果您希望它看起来像上面的图片,我建议使用 FloatingActionButton 代替 imageview

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM