How can I remove the rows separator in a ListView
(if possible within the XML layout file where it's described)?
Set the dividerHeight to zero and divider to null like this in xml:
android:dividerHeight="0dp"
android:divider="@null"
Or in java:
getListView().setDividerHeight(0);
getListView().setDivider(null);
put below property in listview tag (in xml file)
android:divider="@null"
You can set divider color as transparent color and divider height in 'ListView' properties to remove the divider like below:
android:divider="#00000000"
android:dividerHeight="0dp"
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"
Only -1dp helps me to remove divider (not 0, 0.0, @null or the same in code)
Android Studio, SDK L, android 4.2
© 2022 - 2024 — McMap. All rights reserved.