列表视图下方不正常按钮 [英] Listview with button below not working properly
问题描述
我在一个对话框中的ListView,我需要显示列表后的按钮。
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.
我试图添加的android:layout_below =@ ID / lvwScores的按钮,但随后,当列表是空的,我得到了从屏幕到列表的底部,底部运行按钮
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.
如果我删除了android:layout_alignParentBottom =真,那么对话是由小
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.
任何想法?
这是什么样子的空当:
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.
推荐答案
你也许可以给列表视图或列表视图的容器中,它是按钮的高度底部的保证金?正如一个测试,给按钮的30骤降的高度,并有ListView控件或ListView的集装箱有30逢低底边距,看它是否仍然运行在后面的按钮。
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屋!