且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Android中添加按钮到Google Map

更新时间:2023-12-03 16:08:46

尝试这样:

 < RelativeLayout xmlns:android =http://schemas.android.com/apk/res/android
xmlns:tools =http://schemas.android.com/tools
android:layout_width =match_parent
android:layout_height =match_parent
tools:context =。MainActivity>

< fragment
android:id =@ + id / map
android:layout_width =match_parent
android:layout_height =match_parent
class =com.google.android.gms.maps.MapFragment/>

< Button
android:id =@ + id / setRangeButton
android:layout_width =wrap_content
android:layout_height =wrap_content
android:text =@ string / setRange/>
< / RelativeLayout>


I am new to android. I am doing a project as part of my academic. I would like to have few buttons in bottom of the Google Map android like in the waze android application(Sorry that not able to post screen shot). I have tried few things based on the below link How to add buttons at top of map fragment API v2 layout . But did not get desired results.

Can someone please help me with the proper layout. Appreciate your help.

Try this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />

    <Button
        android:id="@+id/setRangeButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/setRange" />
</RelativeLayout>