为什么我的按钮没有显示?
我的按钮根据需要设置大小(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>
为什么我的按钮没有显示?
My button is set to size as needed (wrap_content); it does have a caption, yet it is invisible. It should be right below my ListView, I would think:
<?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>
Why is my button not being displayed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
LinearLayout 的默认方向是水平的。如果你将 android:orientation="vertical" 添加到你的 LinearLayout 那么你应该已经准备好了。
The default orientation for LinearLayout is horizontal. If you add android:orientation="vertical" to your LinearLayout then you should be all set.
像这样在线性布局中添加垂直起点
,并且您不需要将垂直滚动视图属性添加到列表视图...Listview 带有默认的垂直滚动视图
add vertical origination in your linear-layout like this
and you don't need to add vertical scroll view property to the list view... Listview came with the default vertical scroll view
可能是因为 300dip 高度高于屏幕高度?
尝试降低此值,然后看看是否可以看到它
Possibly because 300dip height is higher than the screen height?
Try lowering this and see if you can see it then
尝试更改:
对此:
这很可能是尺寸问题,这将确保您的视图与屏幕的尺寸完全相同。
Try changing:
To this:
It is most likely a size problem, and this will make sure your view is the exact size of your screen.
尝试使用 ListView 页脚添加按钮。
Try to add button using ListView footer.