2014-02-18 49 views
0

嗨我有我的应用程序显示谷歌地图。我基本上想要移动它在屏幕右上角的片段,以便我可以添加其他内容。任何人都可以告诉我从哪里开始?我的布局如下:组织碎片相对布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_width="fill_parent"  
android:layout_height="fill_parent" >  
<fragment   
    android:id="@+id/map"   
    android:name="com.google.android.gms.maps.MapFragment"   
    android:layout_width="wrap_content"   
    android:layout_height="wrap_content"/> 


</RelativeLayout> 
+0

首先添加其他视图,然后相对于视图在您想要的地方放置片段。或者把tfragment放在你想要的地方并且组织相关的视图 – Raghunandan

回答

1

将其他视图添加到您的布局。您可以将该片段相对于其他视图放置。

您可以调整片段的高度和宽度,以满足您的需求

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_width="fill_parent"  
android:layout_height="fill_parent" > 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="50dp" 
     android:layout_marginTop="57dp" 
     android:text="Button" /> 

    <fragment 
    android:id="@+id/map" 
    android:layout_toRightOf="@id/button1" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" /> 

</RelativeLayout> 

enter image description here

或者

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_width="fill_parent"  
android:layout_height="fill_parent" > 

    <fragment 
    android:id="@+id/map" 
    android:layout_alignParentRight="true" 
    android:name="com.google.android.gms.maps.MapFragment" 
    android:layout_width="200dp" 
    android:layout_height="wrap_content" 
    android:layout_alignParentTop="true" /> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/map" 
     android:layout_marginRight="17dp" 
     android:layout_marginTop="149dp" 
     android:layout_toLeftOf="@+id/map" 
     android:text="Button" /> 

</RelativeLayout> 
+0

谢谢,这会给我一个很好的基础:) –