【发布时间】:2014-09-06 11:54:33
【问题描述】:
你如何让ListView 填满屏幕并同时移动下面的视图直到它到达底部?例如,对于下面的图像,我希望“创建”按钮在添加新元素时向下移动屏幕,然后当按钮到达底部时,ListView 开始滚动(创建按钮仍然出现在屏幕)。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
>
<ListView
android:id="@+id/galleryList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
android:layout_alignParentTop="true"
/>
<LinearLayout
android:id="@+id/lowerButtonLayout"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#ffa8269f"
android:layout_alignParentBottom="true"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/button_button_bg_colour"
android:onClick="addRow"
android:text="Create"/>
</LinearLayout>
</RelativeLayout>
【问题讨论】:
-
创建自定义 xml 并将其添加为 ListView 的页脚。并且您必须将 ListView 高度设置为 fill_parent。
-
@dpsingh - 希望这可以完全通过布局来完成
-
另一种方法是在 ScrollView 中使用 ListView。
-
@dpsingh - 我认为它会起作用,但没有
-
好吧,我举个例子
标签: android android-layout android-linearlayout android-relativelayout