2016-07-14 76 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> 
相关问题