Android 为什么我的按钮没有显示?
我的按钮设置为需要的大小(包装内容);它确实有一个标题,但它是看不见的。它应该就在我的ListView下面,我想: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
<?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不会一直延伸到澳大利亚,甚至塔斯马尼亚吗?它会和父视图一样大。。。重点是这是一个测试。。这不是一个解决方案。很好地抓住了方向。