[英]How to place a button at the bottom of the screen while the list(list view) is generated dynamically?
[英]Making a static button in the bottom of the screen with list view
嘿,我正在嘗試為我的活動創建布局,但我無法在屏幕底部制作 static 按鈕,這不會隱藏列表視圖的最后一項。 我看到了很多方法,但它們都隱藏了我的列表視圖的最后一項。 我考慮過使用“重量”參數,但看起來不太好。 我正在嘗試進行的活動在她的頂部有一個圖像視圖,在圖像視圖下方是列表,它不是 static,底部應該是一個 static 按鈕,不會超出列表視圖。 這是我寫的 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.