2016-07-14 38 views
0

我創建了一個叫做「PechhulpActivity」和 谷歌地圖的活動(安卓)我想放置一個按鈕,在它。但是如果我想編輯的活動它給我的錯誤有關片段標籤:爲什麼我不能把小部件在我的活動?

A <fragment> tag allows a layout file to dynamically include different 
layouts at runtime. At layout editing time the specific layout to be 
used is not known. You can choose which layout you would like previewed 
while editing the layout. 

這裏是我的佈局文件夾結構的截圖,起初我還以爲我失蹤了一樣content_pechhulp.xml的文件。如果是這樣,我如何創建正確的?我希望像定製的信息窗口的谷歌地圖的活動,我想它裏面等一個按鈕,我希望你們能幫助我。

enter image description here

編輯:(activity_pechhulp.xml)

<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:map="http://schemas.android.com/apk/res-auto" 
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="match_parent" 
tools:context="com.doppler.stackingcoder.pechhulp.PechhulpActivity" /> 
+0

你能提供你的XML? – faruk

+0

@AlZill是看到編輯 – Stackingcoder

+0

可能重複http://stackoverflow.com/questions/23898992/android-studio-google-map-v2-fragment-rendering – X3Btel

回答

0

嘗試使用RelativeLayout的父,然後用片段像TextView的或按鈕另一種觀點認爲添加子。它將放置在地圖上方。

+0

@ X3Btel我遵循了從鏈接答案的步驟,但我並沒有幫幫忙......(我跟約翰的步驟,我可以看到靜態活動,但我不能放置任何按鈕或東西) – Stackingcoder

0

使用的RelativeLayout或FrameLayout裏作爲parrent這個

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:map="http://schemas.android.com/apk/res-auto" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 
      <fragment 
      android:id="@+id/map" 
      android:name="com.google.android.gms.maps.SupportMapFragment" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      tools:context="com.doppler.stackingcoder.pechhulp.PechhulpActivity"/> 
      <Button 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/your_string_value"/> 
    </RelativeLayout> 
相關問題