Android: нижний колонтитул в ListView - PullRequest
6 голосов
/ 05 августа 2011

У меня есть просмотр списка, как показано ниже

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:background="#E6E7E2">
    <ImageView android:id="@+id/Thumbnail" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:src="@drawable/icon" />
    <TextView android:id="@+id/FilePath" android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:textColor="#E6E7E2"
        />
</LinearLayout>

, и у меня есть нижний колонтитул, как показано ниже

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:layout_gravity="bottom">
    <LinearLayout android:layout_width="fill_parent" 
            android:layout_alignParentBottom="true" 
            android:layout_height="wrap_content"
            android:id="@+id/layoutfooterbutton" android:layout_gravity="bottom">

            <Button android:layout_weight=".30" android:layout_margin="2dp"
                android:layout_height="60dp" android:layout_width="100dp"
                android:textColor="#FFF" android:gravity="bottom|center"
                android:textSize="12dp" android:id="@+id/ButtonAudio" android:background="@drawable/vid_red"/>

            <Button android:layout_weight=".30" android:layout_height="60dp" android:layout_width="100dp"
                android:gravity="bottom|center" android:background="@drawable/redblank"
                android:textColor="#E6E7E2" android:id="@+id/ButtonBrowse" android:layout_marginTop="2dp"/>
            <Button android:layout_weight=".30" android:layout_margin="2dp"
                android:layout_height="60dp" android:layout_width="100dp"
                android:textColor="#FFF" android:gravity="bottom|center"
                android:textSize="12dp" android:background="@drawable/reddelete" android:id="@+id/ButtonDelete"/>

        </LinearLayout>
</RelativeLayout>

Когда я добавляю нижний колонтитул в просмотр списка, используя

View header = getLayoutInflater().inflate(R.layout.header, null);
View footer = getLayoutInflater().inflate(R.layout.footer, null);
ListView lv = getListView();

// setting header for the list view
lv.addHeaderView(header);
lv.addFooterView(footer);
setListAdapter(new ArrayAdapter<String>(AudioListActivity.this, R.layout.row_audio,  R.id.label, db_results));

Идет прямо под последним элементом списка.Я хочу, чтобы нижний колонтитул был внизу.Как мне его достичь ??

PS: Заголовок отлично сидит сверху.

спасибо, что уделили время.

Ответы [ 3 ]

6 голосов
/ 05 августа 2011

для вашего сценария, я думаю, вам нужно что-то похожее на это.

<RelativeLayout>
    <include android:id="@+id/header" layout="@layout/header" android:layout_width="fill_parent" android:layout_alignParentTop="true" />

    <include android:id="@+id/footer" layout="@layout/footer" android:layout_width="fill_parent" android:layout_alignParentBottom="true" /> 

    <ListView android:layout_below="@id/header" android:layout_above="@id/footer"/> 
</RelativeLayout>
3 голосов
/ 05 августа 2011

Работает как задумано. Нижний колонтитул будет в нижней части списка. Если вы хотите, чтобы в нижней части экрана было что-то статичное, вам нужно использовать RelativeLayout с нижним колонтитулом как alignParentBottom и перечислить поверх него.

Ааа, я нашел другой похожий вопрос, и ответ тоже тот же:)

Вид нижнего колонтитула Android View не размещается в нижней части экрана

0 голосов
/ 12 сентября 2017

Попробуйте это ..

<ListView
        android:id="@+id/your_id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:listfooter="@layout/your_layout" />
...