Java 如何在活动地图中添加按钮?
我在创建项目时选择了Google地图活动,如何在布局中添加按钮? 抱歉,如果这是一个愚蠢的问题,我是Android新手Java 如何在活动地图中添加按钮?,java,android,xml,api,google-maps,Java,Android,Xml,Api,Google Maps,我在创建项目时选择了Google地图活动,如何在布局中添加按钮? 抱歉,如果这是一个愚蠢的问题,我是Android新手 <Button android:id="@+id/btn_draw_State" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="right|top" android:layout
<Button
android:id="@+id/btn_draw_State"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right|top"
android:layout_marginTop="55dp"
android:layout_marginRight="11dp" />
布局:
<fragment
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" android:id="@+id/map" tools:context=".MapsActivityWifi"
android:name="com.google.android.gms.maps.SupportMapFragment">
设计用于屏蔽屏幕上显示单个项目的区域。使用或
尝试此操作,并根据需要更改按钮属性
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<fragment
android:layout_width="match_parent"
android:layout_height="instead of match parent try to give a value so that it does not occupy the whole screen"
android:id="@+id/map"
tools:context=".MapsActivityWifi"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
<Button
android:id="@+id/btn_draw_State"
android:layout_below="@id/map"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right|top"
android:layout_marginTop="55dp"
android:layout_marginRight="11dp" />
来自StackOverFlow PT
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivityWifi"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
<Button
android:id="@+id/btn_draw_State"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right|top"
android:layout_marginTop="55dp"
android:layout_marginRight="11dp" />
</FrameLayout>
尝试将所有内容包装在相对布局中,而不是框架框架布局是第二次启动地图,编辑了问题