如何从 android 上的列表视图中删除分隔符?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10163200/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I remove the divider from a listview on android?
提问by FilipeFaria
I'm developing a app that have a Listview
, and the items from list already have a style I don't need the divider.
我正在开发一个具有 的应用程序Listview
,并且列表中的项目已经具有我不需要分隔符的样式。
How do I set as hidden or remove the divider from the ListView
?
如何设置为隐藏或从 中删除分隔线ListView
?
回答by iamtheexplm06
You can try android:divider="@null"
.
你可以试试android:divider="@null"
。
回答by Sotti
There are different ways to achieve this, but I'm not sure which one is the best (I don't even know is there is a best way). I know at least 2 different ways to do this in a ListView:
有不同的方法可以实现这一点,但我不确定哪个是最好的(我什至不知道是否有最好的方法)。我知道至少有 2 种不同的方法可以在 ListView 中执行此操作:
1. Set divider to null:
1. 将分隔符设置为空:
1.1. Programmatically
1.1. 以编程方式
yourListView.setDivider(null);
1.2. XML
1.2. XML
android:divider="@null" (this goes inside your ListView element)
2. Set divider to transparent and set its height to 0 to avoid adding space between listview elements:
2.将divider设置为透明,将其高度设置为0,以避免在listview元素之间添加空间:
2.1. Programmatically:
2.1. 以编程方式:
yourListView.setDivider(new ColorDrawable(android.R.color.transparent));
yourListView.setDividerHeight(0);
2.2. XML
2.2. XML
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
回答by Jawad Zeb
Add
添加
android:divider="@null"
android:dividerHeight="0dp"
to your LIstview
到您的列表视图
<ListView
android:id="@+id/list_of_f"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:divider="@null"
android:dividerHeight="0dp"
android:listSelector="@android:color/transparent" >
</ListView>