某些 ListView 项目下的黑线
我在使用 ListView 时遇到了有趣的问题。它使用标准的 ArrayAdapter,其中的项目具有自定义 XML 布局。简单的 XML:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:background="@drawable/list_bg_blue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:typeface="serif"
android:textSize="20px"
android:textStyle="bold|italic"
android:textColor="#FF1e5a82"
android:shadowColor="#FFFFFFFF"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1"
/>
我不认为其中有任何问题,但出现了一些奇怪的黑线,我似乎无法摆脱它们(您可以在下图中看到它)。我尝试在 ListView 中设置 android:dividerHeight="0px"
,但这些仍然出现。您可以看到新剧集和节目之间没有排队,但由于某种原因,在第一集和最后一集之后有排队。
有什么想法吗?
编辑:做了更多思考,似乎只是第一个和最后一个,所以我发现:
android:headerDividersEnabled
和 android:footerDividersEnabled
将页脚设置为 false 修复了最后一个,但奇怪的是,将页眉分隔符设置为 false 没有效果。 :/
更多编辑!:好的,所以我在列表中添加了更多项目(应该首先完成),并且似乎是所有其他项目(例如项目 1、项目 3、项目 5 等)其下方出现一个分隔线。
Interesting problem I'm having with a ListView. It's using a standard ArrayAdapter, with a custom XML layout for the items within. Simple XML:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:background="@drawable/list_bg_blue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:typeface="serif"
android:textSize="20px"
android:textStyle="bold|italic"
android:textColor="#FF1e5a82"
android:shadowColor="#FFFFFFFF"
android:shadowDx="1"
android:shadowDy="1"
android:shadowRadius="1"
/>
I don't think there's anything in there that is a problem, but I'm having some strange black lines showing up that I can't seem to get rid of (you can see it in the picture below). I've tried setting android:dividerHeight="0px"
in the ListView, but these still appear. You can see between New Episodes and Shows that there is no line, but for some reason there is after the first and last.
Any ideas?
EDIT: Did some more thinking, seems to be just the first and the last, so I found:
android:headerDividersEnabled
andandroid:footerDividersEnabled
Setting footers to false fixed the last one, but oddly setting header dividers to false had no effect. :/
EVEN MORE EDITS!: Okay, so I added a few more items to the list (should have done that first), and it seems to be every other item (e.g. item 1, item 3, item 5, and so on) that has a divider appearing below it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以说
默认情况下应在每个条目之后插入分隔符。
You could say
The divider should be inserted after every entry by default.
我讨厌回答自己的问题,但我找到了解决方案:
这解决了问题。然而,我仍然想知道一种使用 XML 执行此操作的方法,并了解为什么它只在每个其他项目中插入它们。
I hate answering my own question, but I found a solution:
This fixed the problem. I'd still like to know a way to do this with XML, however, and understand why it's inserting them only at every other item.
您可以在 xml 中设置它: android:divider="@null"
You can set it in xml with: android:divider="@null"