The default behavior of Android ListView has a divider line that acts as a separator between two rows as shown in the below image,
If you wish to remove this line, its possible both programmatically as well as using layout xml attributes, lets see both ways,
<ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listViewWithoutSeperator" android:divider="@null" android:layout_below="@+id/fb_login_button" android:layout_toRightOf="@+id/fb_login_button" android:layout_toEndOf="@+id/fb_login_button" android:layout_marginTop="150dp" />
We have seen how to remove the separator line using layout xml property, to achieve this programmatically using Java code, you must create an Object of ListView and map it to the corresponding ListView element and then simply use the function setDivider() with null as argument.
ListView lv = (ListView) findViewById(R.id.listview); lv.setDivider(null);
Code2care'smission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.