简体   繁体   中英

Problem with showing button over google maps android

I'm using google maps in android. Trying to create a layout with google map and some other widgets on the screen like drawer icon. Here is my xml code. The problem I'm facing is drawer icon is visible in xml design layout but when I run the application on device it is not visible.

<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>

界面设计

I have worked with maps but not with google maps, anyway have you tried putting the imageview in the relative layout instead of inside the MapView? RelativeLayouts are made for that purpose, so items init can overlap. not sure if a google maps mapview will accet an 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>

plus if you want it to look just like the image above I would recommend using a FloatingActionButton in place of the imageview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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