2012-03-15 123 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