Android 是否可以在“中添加一个按钮?”;谷歌地图活动“;将控制权传递给另一个活动?
我是android新手,我想添加显示用户当前位置的谷歌地图,我已经用谷歌地图活动完成了。现在我需要的是,我必须启用一个选项来输入目的地,所以我想在地图布局中添加一个按钮。可能吗?如果可能,我如何添加。我选择了这个布局Android 是否可以在“中添加一个按钮?”;谷歌地图活动“;将控制权传递给另一个活动?,android,android-layout,android-fragments,android-activity,Android,Android Layout,Android Fragments,Android Activity,我是android新手,我想添加显示用户当前位置的谷歌地图,我已经用谷歌地图活动完成了。现在我需要的是,我必须启用一个选项来输入目的地,所以我想在地图布局中添加一个按钮。可能吗?如果可能,我如何添加。我选择了这个布局 <fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="
<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=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="@layout/abc_list_menu_item_radio" />
是的,取一个相对布局,将片段和按钮放在相对布局中。 试试这段代码,可能会对你有所帮助
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
tools:context=".MapsActivity"
tools:layout="@layout/abc_list_menu_item_radio" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
是的,取一个相对布局,将片段和按钮放在相对布局中。 试试这段代码,可能会对你有所帮助
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
tools:context=".MapsActivity"
tools:layout="@layout/abc_list_menu_item_radio" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
是的,取一个相对布局,将片段和按钮放在相对布局中。 试试这段代码,可能会对你有所帮助
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
tools:context=".MapsActivity"
tools:layout="@layout/abc_list_menu_item_radio" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
是的,取一个相对布局,将片段和按钮放在相对布局中。 试试这段代码,可能会对你有所帮助
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="500dp"
tools:context=".MapsActivity"
tools:layout="@layout/abc_list_menu_item_radio" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="@+id/button"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>