0

我的按钮设置为需要的大小(wrap_content);它确实有一个标题,但它是不可见的。它应该正好在我的ListView下方,我会认为:为什么我的按钮不被显示?

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

    <ListView 
     android:id="@+android:id/listviewContacts" 
     android:layout_width="match_parent" 
     android:layout_height="300dip" 
     android:scrollbars="vertical | horizontal" > 
    </ListView> 

    <Button 
     android:id="@+id/buttonSaveAndBegin" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/save_settings_and_begin_responding" /> 

</LinearLayout> 

为什么我的按钮不被显示?

回答

4

LinearLayout的默认方向是水平的。如果您将android:orientation =“vertical”添加到LinearLayout,那么您应该全部设置。

+1

很好的方向。 – 2012-02-06 01:46:33

2

可能是因为300dip高度高于屏幕高度?

尝试降低这个,看看你能看出来

+0

不,我可以看到ListView的大纲覆盖了大约2/3的表单。 – 2012-02-05 22:38:55

1

尝试改变:

android:layout_height="300dip" 

要这样:

android:layout_height="match_parent" 

这是最有可能是大小的问题,而这将确保您的视图是屏幕的确切大小。

+0

如果我的列表中有一个gazillion项目,该怎么办?如果我没有指定高度,ListView是否会一直延伸到澳大利亚,甚至塔斯马尼亚? – 2012-02-05 22:40:20

+0

它会和父母一样大......点是它是一个测试..不是解决方案。 – 2012-02-06 01:46:07

3

在您的线性布局这样

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:orientation="vertical" 
     android:layout_height="match_parent" > 

添加垂直始发和你不需要垂直滚动视图属性添加到列表视图列表视图...带着默认的垂直滚动视图

1

尝试使用ListView页脚添加按钮。

相关问题