如何在 Activity 地图中添加按钮?
How do I add a button in my Activity Maps?
我在创建项目的时候选择了一个Google地图activity,如何在布局中添加按钮?
对不起,如果这是一个愚蠢的问题,我是 Android 的新人。
<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">
FrameLayout is designed to block out an area on the screen to display a single item.Use a LinearLayout or a RelativeLayout
试试这个并根据需要更改按钮属性
<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" />
来自 Whosebug 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>
我在创建项目的时候选择了一个Google地图activity,如何在布局中添加按钮? 对不起,如果这是一个愚蠢的问题,我是 Android 的新人。
<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">
FrameLayout is designed to block out an area on the screen to display a single item.Use a LinearLayout or a RelativeLayout
试试这个并根据需要更改按钮属性
<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" />
来自 Whosebug 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>