如下图所示,ListView下面的TextView(页脚)前面出现一条黑线。
我无法理解它是否是由于listview的底部填充或textview的顶部填充,所以我尝试操作xml布局添加android:layout_marginBottom =“0px”和android:paddingBottom =“ 0px“进入listview和android:paddingTop =”0px“和android:layout_marginTop =”0px“进入textview但没有任何作用!
请帮助我,因为我不知道如何解决问题!!!
这里是布局的xmls ......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/header"
android:id="@+id/header"
android:gravity="center"
android:textSize="22sp"
android:background="#777777"
/>
<ListView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/items_list"
android:divider="#00000000"
android:dividerHeight="0px"
android:footerDividersEnabled="false"
android:layout_marginBottom="0px"
android:paddingBottom="0px"
/>
<TextView
android:paddingTop="0px"
android:layout_marginTop="0px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/footer"
android:gravity="center" android:textSize="22sp"
android:background="#777777/>
</LinearLayout>
这里将项目的布局放入listview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="0px"
android:layout_marginBottom="0px"
android:background="#777777">
<TextView
android:layout_width="fill_parent"
android:text="Item List"
android:layout_height="wrap_content"
android:id="@+id/item"
android:textSize="22sp"
/>
<TextView
android:layout_width="fill_parent"
android:text="List Item bottom"
android:layout_height="wrap_content"
android:id="@+id/item2"
android:textSize="14sp"
android:layout_below="@id/item"
android:layout_alignParentBottom="true"
/>
<TextView
android:layout_width="wrap_content"
android:text="List Item right"
android:layout_height="wrap_content"
android:id="@+id/item3"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
/>
</RelativeLayout>
答案 0 :(得分:2)
看起来这是一个错误。有一个hackaround。在ListView
中写下这个:
<ListView ... android:layout_marginBottom="-3dp" />
这将解决此特定问题。
话虽如此,我想再提一次你应该使用ListView.addFooterView()
,或者你可以使用layout_weight
:
<ListView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#888888"
...
/>
选择最适合您的方法。但请注意,“-3dp”是一个黑客,不应该使用(除非你绝望:)。
答案 1 :(得分:0)
尝试将android:footerDividersEnabled属性设置为false,看看是否有帮助。