Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么我的按钮没有显示?_Android_Android Layout_Android Widget_Android Xml_Android Button - Fatal编程技术网

Android 为什么我的按钮没有显示?

Android 为什么我的按钮没有显示?,android,android-layout,android-widget,android-xml,android-button,Android,Android Layout,Android Widget,Android Xml,Android Button,我的按钮设置为需要的大小(包装内容);它确实有一个标题,但它是看不见的。它应该就在我的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="matc

我的按钮设置为需要的大小(包装内容);它确实有一个标题,但它是看不见的。它应该就在我的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>


为什么我的按钮没有显示?

可能是因为300倾斜高度高于屏幕高度

尝试降低此高度,看看是否可以看到,然后尝试更改:

android:layout_height="300dip"
为此:

android:layout_height="match_parent"

这很可能是尺寸问题,这将确保您的视图与屏幕大小完全一致。

线性布局的默认方向为水平。如果您将android:orientation=“vertical”添加到线性布局中,那么您应该已经准备好了。

像这样在线性布局中添加垂直原点

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


您不需要将垂直滚动视图属性添加到列表视图。。。Listview附带默认的垂直滚动视图

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

否,我可以看到Listview的轮廓,大约覆盖表单的2/3。如果我的列表中有大量项目,该怎么办?如果我不指定它的高度,ListView不会一直延伸到澳大利亚,甚至塔斯马尼亚吗?它会和父视图一样大。。。重点是这是一个测试。。这不是一个解决方案。很好地抓住了方向。