2011-06-22 46 views
0

为什么我看不到最后一个LinearLayout?LinearLayout不会出现

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" android:background="@drawable/bg" android:layout_height="wrap_content" 
android:orientation="vertical" android:padding="2dp" 
android:theme="@android:style/Theme.NoTitleBar"> 

    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" .../> 

    <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content"> 
     <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     // TableRows created dynamically 
     </TableLayout> 
    </ScrollView> 

    <LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_gravity="bottom"> 
     <Button android:layout_height="wrap_content" 
     android:layout_width="wrap_content" android:text="Button" android:id="@+id/button1"></Button> 
    </LinearLayout> 
</LinearLayout>` 

编辑:机器人:layout_gravity =“底”

+1

为什么DONOT你去的RelativeLayout与alignparentBottom =真 –

回答

2

这种事情会发生,因为ü已经把孩子第一挂面布局和滚动视图可能与屏幕相比具有更多空间,因此此班轮布局的最后一个孩子没有更多空间供其查看。

对于解决方案,你可以采取相对布局为此或把layout_weight的所有子视图按照您的要求。我认为最后的选择是对你的击球手。

+0

RelativeLayout的是更好地使带有按钮的菜单底部 – coffee

+0

使用layout_weight为linerLayout ..要了解这个请参考这个[链接](http://developer.android.com/resources/tutorials/views/hello-linearlayout.html) – dhams

1

我几乎没有与Android的布局舒服,因为我想,但我认为这可能是因为你的滚动型里面有什么。您将ScrollView的参数设置为wrap_content,这意味着它的大小与子级需要的一样大。但嵌套的TableLayout使用fill_parent,所以ScrollView“继承”并填充整个屏幕。再一次,我不保证这实际上是正确的。

+0

我只是想用FILL_PARENT仅对宽度 – coffee

+0

IM,但你的答案可以帮助我 – coffee

1

因为最有可能高于去年的线性布局的内容是如此之大,没有留下最后的线性布局出足够的空间,它的按钮出现