如何解决在具有列表视图的屏幕底部制作一个静态按钮
| 嘿,我正在尝试为我的活动创建布局,但是我无法在屏幕底部创建一个静态按钮,该按钮不会隐藏列表视图的最后一项。 我看到了很多方法,但是所有方法都隐藏了列表视图的最后一项。 我曾考虑使用\“ weight \”参数,但是看起来不太好。 我要进行的活动在顶部具有图像视图,在图像视图下方是列表,该列表不是静态的,而在底部下方是一个静态按钮,该按钮不会位于列表视图上方。这是我编写的xml,但是如您所见,如果尝试“运行”它(只需在表布局中添加一些内容),则如果该列表很长,则将其隐藏在按钮下方。 PS:我正在构建列表视图,因此现在它是表格布局。 <?xml version=\"1.0\" encoding=\"utf-8\"?>
<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_height=\"fill_parent\" android:layout_width=\"fill_parent\"
android:background=\"@drawable/background\">
<ImageView android:src=\"@drawable/search_title\"
android:layout_alignParentTop=\"true\" android:layout_height=\"wrap_content\"
android:layout_width=\"wrap_content\" android:paddingTop=\"10dip\"
android:layout_gravity=\"center\" android:id=\"@+id/shop_list_title\" />
<ScrollView android:layout_marginBottom=\"1dip\"
android:layout_height=\"wrap_content\" android:layout_width=\"fill_parent\"
android:layout_below=\"@id/shop_list_title\">
<TableLayout android:id=\"@+id/shop_list_list\"
android:layout_width=\"fill_parent\" android:layout_height=\"wrap_content\">
</TableLayout>
</ScrollView>
<Button android:id=\"@+id/shop_list_search_button\" android:layout_alignParentBottom=\"true\"
android:layout_height=\"wrap_content\" android:layout_width=\"fill_parent\"
android:text=\"@string/search_button_shoplist\" />
</RelativeLayout>
预先感谢,埃拉德!
解决方法
我建议您使用
LinearLayout
。
这是一个例子。我删除了所有嘈杂的内容,只保留了相关属性:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_height=\"fill_parent\"
android:layout_width=\"fill_parent\" >
<ImageView
android:layout_height=\"wrap_content\"
android:layout_width=\"wrap_content\" />
<ScrollView
android:layout_width=\"fill_parent\"
android:layout_height=\"0dp\"
android:layout_weight=\"1\"
android:fillViewport=\"true\" >
<TableLayout
android:layout_width=\"fill_parent\"
android:layout_height=\"wrap_content\">
</TableLayout>
</ScrollView>
<Button
android:layout_width=\"fill_parent\"
android:layout_height=\"wrap_content\" />
</LinearLayout>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。