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

发布于 2025-01-03 07:09:55 字数 812 浏览 4 评论 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>

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

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

超可爱的懒熊 2025-01-10 07:09:55

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.

乖乖哒 2025-01-10 07:09:55

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

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

,并且您不需要将垂直滚动视图属性添加到列表视图...Listview 带有默认的垂直滚动视图

add vertical origination in your linear-layout like this

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

and you don't need to add vertical scroll view property to the list view... Listview came with the default vertical scroll view

总攻大人 2025-01-10 07:09:55

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

尝试降低此值,然后看看是否可以看到它

Possibly because 300dip height is higher than the screen height?

Try lowering this and see if you can see it then

携君以终年 2025-01-10 07:09:55

尝试更改:

android:layout_height="300dip"

对此:

android:layout_height="match_parent"

这很可能是尺寸问题,这将确保您的视图与屏幕的尺寸完全相同。

Try changing:

android:layout_height="300dip"

To this:

android:layout_height="match_parent"

It is most likely a size problem, and this will make sure your view is the exact size of your screen.

逆蝶 2025-01-10 07:09:55

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

Try to add button using ListView footer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文