如何在我的 Mapbox 图层的左上角添加导航菜单和抽屉
How do I add navigation menu and drawer on top left side top of my Mapbox layer
我想在 'MapboX map' 层的顶部添加导航菜单和抽屉。
我在下面添加了我的 'RelativeLayout',也请参见附图。
谁能帮我实现如何在地图层顶部添加菜单和导航抽屉。
<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"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.mycompany.myfirstglapp.MainActivity">
<TextView
android:text="Hello mate!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/locate1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:onClick="myButton"
android:text="@string/locate_me"
android:background="#1880c9"/>
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:style_url="@string/style_mapbox_streets"
mapbox:center_latitude="-36.91044"
mapbox:center_longitude="174.88203"
mapbox:zoom="12"/>
</RelativeLayout>
我会尽我所能引导你完成这个过程,有很多教程解释了如何将导航抽屉添加到应用程序,你甚至可以开始一个 Android 项目,其中包含一个应用程序。由于这些原因,我不会详细介绍如何添加导航抽屉本身。如果您不想要工具栏(虽然大多数应用程序都使用工具栏),而只想在地图顶部显示抽屉按钮,您需要使用 ImageButton
并有一个 onClick 事件,它将事件发生时打开抽屉。由于您使用的是相对布局,因此 xml 可能如下所示:
<ImageButton
android:id="@+id/drawer_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/<your button image>"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
希望这可以帮助您入门。
<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"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.mycompany.myfirstglapp.MainActivity">
<TextView
android:text="Hello mate!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/locate1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:onClick="myButton"
android:text="@string/locate_me"
android:background="#1880c9"/>
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapbox:style_url="@string/style_mapbox_streets"
mapbox:center_latitude="-36.91044"
mapbox:center_longitude="174.88203"
mapbox:zoom="12"/>
</RelativeLayout>
我会尽我所能引导你完成这个过程,有很多教程解释了如何将导航抽屉添加到应用程序,你甚至可以开始一个 Android 项目,其中包含一个应用程序。由于这些原因,我不会详细介绍如何添加导航抽屉本身。如果您不想要工具栏(虽然大多数应用程序都使用工具栏),而只想在地图顶部显示抽屉按钮,您需要使用 ImageButton
并有一个 onClick 事件,它将事件发生时打开抽屉。由于您使用的是相对布局,因此 xml 可能如下所示:
<ImageButton
android:id="@+id/drawer_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/<your button image>"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
希望这可以帮助您入门。