顶部和底部的分隔没有显示在Android的列表视图 [英] Top and bottom dividers not showing in Android listview

查看:179
本文介绍了顶部和底部的分隔没有显示在Android的列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,对于一个列表视图定义的分应该出现在列表的顶部和底部也一样,即上述第一项和最后一项下。

The way I understand it, the divider defined for a listview should appear at the top and bottom of the list too, i.e. above the first item and under the last item.

有关某种原因,他们不会出现在我的列表视图:

For some reason they don't appear in my listview:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="@drawable/background">

<ImageView
    android:id="@+id/home"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingLeft="3dp"
    android:paddingTop="3dp"
    android:paddingBottom="3dp"
    android:src="@drawable/homeicon"/>

<TextView
    android:id="@+id/titleBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Page Title" 
    android:layout_marginLeft="10dp" 
    android:paddingTop="3dp"
    android:textSize="18sp" 
    android:textStyle="bold" 
    android:typeface="serif" 
    android:textColor="#FFFFFF"
    android:layout_centerHorizontal="true"/>

<ImageView
    android:id="@+id/back"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingRight="8dp"
    android:paddingTop="8dp"
    android:src="@drawable/backicon" 
    android:layout_alignParentRight="true"/>


<ImageView
    android:id="@+id/separator1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/home"
    android:scaleType="fitXY"
    android:src="@drawable/separatorimg" />


<ListView
    android:id="@android:id/android:list" 
    android:layout_below="@+id/separator1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:cacheColorHint="#00000000"
    android:divider="@drawable/separatorimg">
</ListView>

</RelativeLayout>

设置的android:footerDividersEnabled为true(这是在其他周围的物质的问题给出的答案)不会改变任何东西。另外我有没有禁用的项目,除非有某种方式,将被禁用默认页脚。

Setting android:footerDividersEnabled to true (which is the answer given in other questions around that matter) doesn't change anything. Also I have no disabled items, unless there is somehow a default footer that would be disabled.

任何想法?

编辑:看来分频器在顶部和底部的分隔第二出现的一瞬间,当我滚动过去的第一个/最后一个项目,然后消失。它看起来好像界面会继续,只是后来意识到那是最后一个项目,然后禁用分频器。

It seems the divider at the top and bottom dividers appear for a split second when I scroll past the first/last item, and then disappears. It looks as if interface was going to continue, only later to realize that was the last item and then disable the divider.

推荐答案

我解决了从下面的链接使用帮助,这个问题:<一href="http://stackoverflow.com/questions/5661668/divider-disappears-from-last-item-in-listview-if-footerview-added">Divider从最后一项消失在列表视图,如果footerview添加

I solved this problem using help from the following link: Divider disappears from last item in listview if footerview added

我所做的是添加

  android:footerDividersEnabled="true" 

属性在XML中的ListView。然后编程,我添加了一个空的页脚视图使用是可选的。

attribute to the ListView in XML. Then programatically, I added an empty footer view that was selectable using

 listView.addFooterView(new View(context), null, true);

我没有尝试的头,但我希望它的工作方式相同。

I didn't try the header, but I expect it to work the same way.

这篇关于顶部和底部的分隔没有显示在Android的列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆