2013-07-02 47 views
10

我想要創建此佈局,但我無法在片段上設置文本圖像。我設置佈局的要求與我在附圖中顯示的一樣。在地圖片段頂部設置textview

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayoutFragment" 
    android:layout_width="match_parent" 
    android:layout_height="fill_parent" > 

    <!-- ListRow Left sied Thumbnail image --> 

    <LinearLayout 
     android:id="@+id/thumbnail" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_marginRight="5dip" 
     android:background="@drawable/image_bg" 
     android:padding="3dip" 
     android:orientation="horizontal"> 

     <ImageView 
      android:id="@+id/list_image" 
      android:layout_width="50dip" 
      android:layout_height="50dip" 
      android:src="@drawable/atm" /> 
    </LinearLayout> 

    <!-- Name of ATM --> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignTop="@+id/thumbnail" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:textColor="#040404" 
     android:textSize="15dip" 
     android:textStyle="bold" 
     android:typeface="sans" /> 

    <!-- Location --> 

    <TextView 
     android:id="@+id/location" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/title" 
     android:layout_marginTop="1dip" 
     android:layout_toRightOf="@+id/thumbnail" 
     android:textColor="#343434" 
     android:textSize="10dip" /> 


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

</RelativeLayout> 

enter image description here

+0

發佈您試過的代碼 – amalBit

+0

@amalBit我已更新代碼..請檢查它 –

+0

檢查此答案..它涵蓋了你的問題,我猜[。鏈接。](http://stackoverflow.com/a/14706956/2219600) – amalBit

回答

29

認沽地圖片段在第一個(訂貨事宜!)你RelativeLayout(所以這將是在 「底部」)。然後(至少我會這樣做是爲了簡單)將你想要的疊加在另一個容器中的所有項目(即LinearLayoutRelativeLayout),將容器放置在視圖頂部,而且大部分都已完成。

+1

很好的答案!關鍵是放置地圖片段首先 –

+1

簡單優雅... – CodeSlave