how to show a floating view on google map just like the search bar in Google Maps

前端 未结 1 1144
情深已故
情深已故 2021-01-26 18:20

I have implemented map successfully, but I couldn\'t find any help regarding this here is my implementation of google map fragment

SupportMapFragment fragment;
          


        
相关标签:
1条回答
  • 2021-01-26 19:11

    Here is my answer, it may help someone. What I did is placed toolbar inside CoordinatorLayout and applied some margin to AppBarLayout.

    <android.support.design.widget.CoordinatorLayout 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:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".activity.MapActivity">
    
    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:theme="@style/AppTheme.AppBarOverlay">
    
        <include layout="@layout/toolbar" />
    
    </android.support.design.widget.AppBarLayout>
    
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    
    </android.support.design.widget.CoordinatorLayout>
    

    Below is the output of above code.

    0 讨论(0)
提交回复
热议问题