具有以下按钮的列表视图不能正常工作 [英] Listview with button below not working properly
问题描述
我在对话框中有一个ListView,我需要在列表后面显示一个按钮。
<?xml版本=1.0encoding =utf-8?>
< RelativeLayout
xmlns:android =http://schemas.android.com/apk/res/android
android:layout_width =fill_parentandroid:layout_height =wrap_content >
< TextView android:id =@ + id / tvwGameOverandroid:layout_weight =1android:gravity =center
android:textSize =25spandroid:visibility =gone
android:layout_width =fill_parentandroid:layout_height =wrap_content/>
< LinearLayout
android:id =@ + id / lloPlayerNamesxmlns:android =http://schemas.android.com/apk/res/android
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:orientation =horizontalandroid:footerDividersEnabled =true
android:headerDividersEnabled =trueandroid:layout_below =@ id / tvwGameOver >
< TextView
android:id =@ + id / tvwGameNumberHeaderandroid:layout_weight =1android:gravity =right
android:text =@ string / scores_GameNumber android:textSize =12sp
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:layout_marginRight =13sp/>
< TextView
android:id =@ + id / tvwPlayer0Nameandroid:layout_weight =1android:gravity =right
android:textSize =12sp
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:layout_marginRight =13sp/>
< TextView
android:id =@ + id / tvwPlayer1Nameandroid:layout_weight =1android:gravity =right
android:textSize =12sp
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:layout_marginRight =13sp/>
< TextView
android:id =@ + id / tvwPlayer2Nameandroid:layout_weight =1android:gravity =right
android:textSize =12sp
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:layout_marginRight =13sp/>
< TextView
android:id =@ + id / tvwPlayer3Nameandroid:layout_weight =1android:gravity =right
android:textSize =12sp
android:layout_width =fill_parentandroid:layout_height =wrap_content
android:layout_marginRight =13sp/>
< / LinearLayout>
< ListView
android:id =@ + id / lvwScoresandroid:layout_below =@ id / lloPlayerNames
android:layout_width =fill_parent android:layout_height =wrap_content
android:divider =#FFFFFFandroid:dividerHeight =1dip
android:layout_weight =1
android:footerDividersEnabled =true :headerDividersEnabled =true/>
< Button android:id =@ + id / btnOK
android:layout_height =wrap_contentandroid:layout_width =120dip
android:layout_weight =1
android:text =OKandroid:layout_centerHorizontal =true
android:layout_alignParentBottom =true
/>
< / RelativeLayout>
问题是,当列表变得太大时,只需传递按钮,按钮就位于列表顶部。
我试图添加android:layout_below =@ id / lvwScores到按钮,但是当列表为空时,我得到一个按钮,从屏幕底部到列表底部。
如果我删除了android:layout_alignParentBottom =true,那么对话框就变小了。 / p>
在一天结束的时候,我正在寻找列表填充大部分的屏幕,即使它的一部分仍然是空的(它是一个分数屏幕),与
任何想法?
这是空的时候的样子:
这很棒,除了当列表建立并到达底部是不停止在按钮。
可以你可以给列表视图或列表视图的容器在底部的边距是按钮的高度?作为一个测试,给按钮一个高度30蘸,并且listview或listview的容器的底部边距为30蘸,看看它是否仍然在按钮后面。
I have a ListView in a dialog and I need to show a button after the list.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:id="@+id/tvwGameOver" android:layout_weight="1" android:gravity="center"
android:textSize="25sp" android:visibility="gone"
android:layout_width="fill_parent" android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal" android:footerDividersEnabled="true"
android:headerDividersEnabled="true" android:layout_below="@id/tvwGameOver">
<TextView
android:id="@+id/tvwGameNumberHeader" android:layout_weight="1" android:gravity="right"
android:text="@string/scores_GameNumber" android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer0Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
<TextView
android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
android:textSize="12sp"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_marginRight="13sp"/>
</LinearLayout>
<ListView
android:id="@+id/lvwScores" android:layout_below="@id/lloPlayerNames"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:divider="#FFFFFF" android:dividerHeight="1dip"
android:layout_weight="1"
android:footerDividersEnabled="true" android:headerDividersEnabled ="true"/>
<Button android:id="@+id/btnOK"
android:layout_height="wrap_content" android:layout_width="120dip"
android:layout_weight="1"
android:text="OK" android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Problem is that when the list gets to be too big it just passes the button and the button sits over the top of the list.
I tried to add android:layout_below="@id/lvwScores" to the button but then, when the list is empty, I get a button that runs from the bottom of the screen to the bottom of the list.
If I remove the android:layout_alignParentBottom="true" then the dialog is made small.
At the end of the day, I am looking to have the list filling most of the screen even if part of it is still empty (it is a scores screen), with the button at the bottom.
Any ideas?
This is what it looks like when empty:
It is great, except that when the list builds up and reaches the bottom is down not stop at the button.
Can you maybe give the list view or the list view's container a margin at the bottom that is the height of the button? Just as a test, give the button a height of 30 dips and have the listview or listview's container have a bottom margin of 30 dips to see if it still runs over behind the button.
这篇关于具有以下按钮的列表视图不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!