在android上的列表视图下方添加一个按钮

2023-11-27

所以我一直在尝试在android中的列表视图下添加一个按钮,问题是该按钮没有出现。

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
    android:id="@+id/widget0"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ListView
        android:id="@+id/messagelist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="0px"
        android:layout_y="0px">
    </ListView>
    <Button
        android:id="@+id/addbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button"
        android:layout_x="0px"
        android:layout_y="379px">
    </Button>
</AbsoluteLayout>

AbsoluteLayout 已弃用。我建议您使用 LinearLayout:

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

    <ListView
        android:id="@+id/messagelist"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1">
    </ListView>
    <Button
        android:id="@+id/addbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button">
    </Button>
</LinearLayout>

我还建议阅读开发者文档布局上有一个很好的介绍。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在android上的列表视图下方添加一个按钮 的相关文章

随机推荐