Добавление кнопки под listview на андроиде

Таким образом, я пытался добавить кнопку под listview в андроиде, проблема состоит в том, что кнопка не появляется.

<?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>
7
задан Pallinder 26 February 2010 в 16:07
поделиться

1 ответ

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>

Я бы также посоветовал прочитать документацию разработчика по макетам для хорошего введения.

6
ответ дан 7 December 2019 в 07:44
поделиться
Другие вопросы по тегам:

Похожие вопросы: