簡體   English   中英

在屏幕底部使用列表視圖制作 static 按鈕

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM