2013-05-07 93 views
0

我試圖找到一種方式來佈局Android的佈局如下:如何在Android的一個複雜的Layout佈局

enter image description here

凡爲(4)爲背景色,這應該是居中在屏幕的底部並且正好是屏幕的1/3寬度。 (1),(2),(3)是圖像,其中(1)和(2)應該位於(4)內部的中心,並且(3)應該位於(4)的右上角的中心。

沒有什麼工作對我來說:(

如何使用Android的佈局。這一個

編輯:

我成功地創建(1)+(2)+(4),但。沒有運氣(3)這裏是我的代碼:

<LinearLayout 
     android:id="@+id/layout4" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:layout_marginBottom="50dp" 
     android:gravity="center" 
     android:weightSum="1.0" > 

     <LinearLayout 
      android:id="@+id/layoutSaveShare_inner" 
      android:layout_width="0dp" 
      android:layout_height="50dp" 
      android:layout_weight="0.33" 
      android:background="@color/light_blue" 
      android:gravity="center" 
      android:orientation="horizontal" 
      android:weightSum="1.0" > 

      <ImageView 
       android:id="@+id/img1" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.43" 
       android:src="@drawable/btn1" /> 

      <ImageView 
       android:id="@+id/img2" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.43" 
       android:src="@drawable/btn2" /> 
     </LinearLayout> 
    </LinearLayout> 

感謝

+0

您不能在xml佈局中將視圖放置在3的中心周圍。 – Luksprog 2013-05-07 14:45:52

+0

我不需要那個。 (4)在屏幕中居中,(3)應按照(4)放置 - 在其右上角 – Roman 2013-05-07 14:53:55

+0

從您的圖像看起來像4的右上角正好在3的中心。您不要不想要這個? – Luksprog 2013-05-07 14:56:57

回答

0

怎麼樣的東西如T他跟隨sudo代碼:

<someParentLayout> 
<____Layout android:weight="33"> 
    <child items> 
</_____Layout> 
<RelativeLayout android:weight="67" 
     android:background="blah"> 
     <TextView android:id="@+id/center_reference" 
      android:layout_height/width="0dp" 
      android:layout_centerInParent="true"/> 
     <Images 2 & 3 to the left and right of "center_reference" 
      android:layout_centerVertical="true"/> 
</RelativeLayout> 
</someParentLayout> 

唯一需要實驗的部分是#3,我對此不太確定。

+0

謝謝,但我設法做到這一部分...問題是(3)在我的圖紙 – Roman 2013-05-07 14:42:46

+0

嗯..如果你想它的方式,你描述它的文字,不會放在右邊的一半圖像離開屏幕? – TronicZomB 2013-05-07 14:43:47

+0

不。 (4)位於屏幕中央,僅爲屏幕的1/3 - 因此(3)仍在智能手機屏幕內 – Roman 2013-05-07 14:44:41