У меня есть Activity с ListView и с кнопками в самом низу. Как мне сделать так, чтобы прокручивался только ListView, а не весь Activity, и чтобы не пропадали кнопки внизу экрана.
Код Activity:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:id="@+id/activity_main_listView"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/activity_main_start"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Start" />
<Button
android:id="@+id/activity_main_stop"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Stop" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/activity_main_clear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Clean" />
<Button
android:id="@+id/activity_main_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Refresh" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Обновление
Если я помещаю кнопки вверху экрана, то список не получается, всё так, как мне надо. (Список прокручивается, но экран вместе с ним не прокручивается и кнопки находятся вверху). А мне надо, чтобы было так же, но кнопки были внизу.
layout_alignParentBottom
, у Listview уберите внешний слой (он не нужен) и сделайте емуlayout_above
.