Elad Benda2
Elad Benda2

Reputation: 15522

how to disable a black border between my listView in android?

I have a listView in my android app.

There is a black border between the List items, show their bg has no such.

What property can cause that?

    <ListView android:layout_width="match_parent"
        android:layout_height="wrap_content" android:id="@+id/rtalterts_menu_listmenu"
        android:cacheColorHint="#00000000"
        android:scrollbars="none" android:padding="0dp"
        android:fadingEdge="none">
    </ListView>

row xml:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:id="@+id/rtalerts_menu_row_container"
  android:padding="2dp"
  >

  <ImageView
    android:layout_marginLeft="10dp"
    android:layout_width="50dp"
    android:layout_height="64dp"
    android:id="@+id/rtalerts_menu_row_image"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:scaleType="center">
  </ImageView>

</RelativeLayout>

in my list adapter:

holder.container.setBackgroundResource( R.drawable.item_selector_middle );

Upvotes: 0

Views: 282

Answers (6)

Pankaj Arora
Pankaj Arora

Reputation: 10274

<ListView
    ...
    android:divider="#00000000"
    ...
/>

Upvotes: 0

Invader
Invader

Reputation: 679

I think that called divider

listview.setDividerHeight(0);

and try all other other properties

Upvotes: 0

grexter89
grexter89

Reputation: 1102

It's because you set the cacheColorHint to black and your ImageView in the item doesn't fill its parent (at least due to its margin, but maybe also because its fixed width and height).

Upvotes: 0

Hareshkumar Chhelana
Hareshkumar Chhelana

Reputation: 24848

// set this properties to list
android:cacheColorHint="#00000000"
android:divider="@null"
android:dividerHeight="0dp"

Upvotes: 0

A.S.
A.S.

Reputation: 4574

In your

  <ListView
    android:id="@+id/friendlist_lv_list"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginTop="10dp"
    android:layout_weight="4"
    android:cacheColorHint="#00000000"
    android:divider="#00000000"
    android:dividerHeight="4dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:scrollbars="none" >
 </ListView>

These two lines do the trick:

 android:divider="#00000000"
 android:dividerHeight="4dp"

it defines the devider to be transparent and gives it a spacing of 4px

Upvotes: 0

SweetWisher ツ
SweetWisher ツ

Reputation: 7306

Add this to your xml

  <ListView
        ...
        android:divider="@android:color/transparent"
        ...
    />

The divider should be inserted after every entry by default.

Upvotes: 4

Related Questions