我的理解是,为列表视图定义的分隔线应该出现在列表的顶部和底部,即在第一个项目的上方和最后一个项目的下方。顶部和底部的分隔线不显示在Android列表视图
因为他们不会出现在我的列表视图某些原因:
<?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>
设置机器人:footerDividersEnabled为true(这是在围绕这个问题其他问题给出的答案)不会改变任何东西。此外,我没有禁用的项目,除非有某种默认页脚会被禁用。
任何想法?
编辑:当我滚动过第一个/最后一个项目,然后消失时,似乎顶部和底部的分隔线出现一瞬间。它看起来好像接口将继续,只是在后来才意识到这是最后一项,然后禁用分频器。
感谢您的回答,不幸的是,这并不适合我。首先,该视图仅显示其下面是否有其他元素(不知道为什么),其次,即使显示,它仍保持始终可见在屏幕的底部。我试图达到的效果是,分频器只出现在列表的末尾,就像它随着它滚动一样。 – InterRaptor
你尝试过吗?因为它按照你想要的方式工作 –
我试了一下,在接受的答案中复制了代码(替换listview id)在listview下方。即使有许多列表项目仍然需要滚动,我仍然会在屏幕底部出现一条绿线。 – InterRaptor