2012-03-15 73 views
1

我有兩個lenear佈局在我的xml &第一個佈局高度爲&寬度作爲fill_parent。 現在在下面的部分,我想顯示第二個佈局也是第一個佈局。可能嗎 ? 我的XML代碼如下兩個線性佈局顯示

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#e0ffff" > 

    <TableLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 

     <TableRow> 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="20dip" 
       android:layout_marginTop="20dip" 
       android:src="@drawable/Catlog" > 
      </ImageView> 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="30dip" 
       android:layout_marginTop="20dip" 
       android:src="@drawable/Mycatlog" > 
      </ImageView> 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="40dip" 
       android:layout_marginTop="20dip" 
       android:src="@drawable/Events" > 
      </ImageView> 
     </TableRow> 

     <TableRow> 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="20dip" 
       android:layout_marginTop="20dip" 
       android:src="@drawable/Lerningprofiles" > 
      </ImageView> 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="20dip" 
       android:layout_marginTop="20dip" 
       android:src="@drawable/Profile" > 
      </ImageView> 
     </TableRow> 
    </TableLayout> 
</LinearLayout> 

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#0F304C" 
    android:orientation="horizontal" 
    android:weightsum="0.05" > 

    <ImageView 
     android:layout_width="100px" 
     android:layout_height="100px" 
     android:layout_marginLeft="20dip" 
     android:layout_marginTop="20dip" 
     android:src="@drawable/Profile" > 
    </ImageView> 
</LinearLayout> 
+0

你必須更具體一點。請發佈您的XML佈局代碼.. – Ghost 2012-03-15 05:25:06

+1

fill_Parent意味着第一個佈局本身將佔據屏幕上的整個空間,第二個佈局將永遠不會出現在屏幕上。考慮到它們是垂直定向的。請將您的xml複製到此處,然後我們可以建議更好。 – Deva 2012-03-15 05:27:02

+0

我已經添加了代碼plz chek it – user1196969 2012-03-15 05:54:22

回答

0

不,相反,你可以使用相對佈局父佈局,然後把一個線性佈局,其child..I認爲這可以給你want..because Android的看法:除非是的LinearLayout裏面嵌套一個RelativeLayout的

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
... 
<LinearLayout 
.... 
0

我無法理解你具有顯示最終ImageView的一個單獨的LinearLayout的原因layout_alignParentBottom =「真正的」沒有任何效果。雖然是

<TableRow > 

      <ImageView 
       android:layout_width="100px" 
       android:layout_height="100px" 
       android:layout_marginLeft="20dip" 
       android:layout_marginTop="20dip" 
       android:background="#0F304C" 
       android:src="@drawable/ic_launcher" > 
      </ImageView> 

     </TableRow> 

幾個建議:

  1. 不要直接在您的佈局中使用像素值

    同樣可以僅僅通過增加一個第三像下面顯示。

  2. 嘗試使用layoutopt命令行工具來處理所有佈局 以獲得更好的性能和優化的佈局。

+0

,因爲我希望它是最底部的,我不想提供硬編碼值 – user1196969 2012-03-15 07:38:44

+0

如果你給了表格,甚至那麼ImageView裏面的ImageView就會出現在底部。 – Deva 2012-03-15 08:34:32