簡體   English   中英

帶有片段的Android Google Maps

[英]Android Google Maps with Fragment

我在Android Studio中使用片段創建了一個新的空白活動,並且需要使用SupportMapFragment包含Google Map。 在布局的頂部,我要保留工具欄,該工具欄默認顯示活動名稱。 怎么做還是有教程嗎?

是的,這里有一個教程對此進行了很好的解釋: http : //www.truiton.com/2013/05/android-supportmapfragment-example/

但是要保留工具欄,只需將其添加到您的xml活動中(而不是如教程所述),而不是對其進行完全修改,因為您可能在xml中定義了工具欄,如下所示:

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" >

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

</RelativeLayout>

在tools:context上,在活動類名稱前添加。 (點)。

調整相對布局的寬度和高度,以滿足您的需求。 例如200dp或將其保留為match_parent。

如果您需要更多幫助,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM