Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove the divider from a listview on android? [duplicate]

I'm developing a app that have a Listview, and the items from list already have a style I don't need the divider.

How do I set as hidden or remove the divider from the ListView?

like image 658
FilipeFaria Avatar asked Apr 15 '12 15:04

FilipeFaria


People also ask

How to remove divider in ListView Android?

To remove the separator using XML property you must simply add android:divider="@null" property to the ListView View that you have defined in the layout file.

How to remove ListView line in Android?

This example demonstrates how do I remove lines between listviews on android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.


3 Answers

You can try android:divider="@null".

like image 123
iamtheexp01 Avatar answered Oct 18 '22 11:10

iamtheexp01


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"
like image 43
Sotti Avatar answered Oct 18 '22 11:10

Sotti


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>
like image 4
Zar E Ahmer Avatar answered Oct 18 '22 10:10

Zar E Ahmer