【发布时间】:2013-04-17 17:51:01
【问题描述】:
我有一个对话框,其中有一个列表(TextViews 在LinearLayout 内)在ScrollView 内。布局如下:
<?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"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/delete_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<ScrollView
android:id="@+id/filename_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/filename_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
<View
android:id="@+id/horisontal_separator"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" />
<LinearLayout
android:id="@+id/button_container"
android:layout_width="match_parent"
android:layout_height="48dp" >
<Button
android:id="@+id/load_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/button_load"
android:gravity="center"
android:layout_weight="1" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="@android:color/darker_gray" />
<Button
android:id="@+id/delete_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/button_delete"
android:gravity="center"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
看起来像这样,列表中只有几个项目:
但是当屏幕上无法容纳的内容(并且实际需要滚动)时,我的按钮会被推到屏幕下方。当一直滚动到底部时,它看起来像这样:
我需要包含按钮的LinearLayout 保留作为页脚,它不应该滚动到任何地方并且显然不会消失。我试过摆弄布局高度和重量,但无济于事。
【问题讨论】:
-
您是否尝试将 ListView 设置为固定高度,例如 200dip?
-
我没有实际的
ListViewthere,但更改LinearLayout的高度并没有什么不同。如果我改变ScrollView的高度,它只会再次推出按钮。
标签: android android-layout scrollview