It seems that there is a horizontal line by default at the bottom of each 开发者_如何学Pythonitem in android listview. My problem is: how to let the line not display
You can do using this code..
lvlist.setDivider(null);
lvlist.setDividerHeight(0);
in xml:
android:divider="@null"
android:dividerHeight="0dp"
and in java you can use this:
myList.setDivider(null);
myList.setDividerHeight(0);
Check here: How to change color of Android ListView separator line?
You can try setting the divider height to 0px.
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:
1. Set divider to null:
1.1. Programmatically
yourListView.setDivider(null);
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.1. Programmatically:
yourListView.setDivider(new ColorDrawable(android.R.color.transparent));
yourListView.setDividerHeight(0);
2.2. XML
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
精彩评论