2

I am implementing a list view like this for Android.

beautiful list view

Without worrying about selectors and the thin strip on the left of each item, the background layout drawable for list items would be:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <stroke android:width="1dp" android:color="#000000" />
    <corners
        android:bottomRightRadius="27dp"
        android:topRightRadius="27dp" />
</shape>

And I'm calling it list_border.xml and it resides in the drawable folder.

I have tried to set it as the background for the listview

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/list_padding"
    android:paddingRight="@dimen/list_padding"
    android:divider="@drawable/list_border"/>

and as the background for each list item

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:divider="@drawable/list_border" >

    <ImageView
        android:id="@+id/menu_icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/arrow1_e" />

    <org.bitbucket.infovillafoundation.denko.customui.MyanmarTextView
        android:id="@+id/menu_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/menu_icon" />
</RelativeLayout>

But the listview has not changed to reflect the new background. Is anything wrong with it?

Sandah Aung
  • 6,156
  • 15
  • 56
  • 98

2 Answers2

3

For listview you are setting it for divider not background. Check it and rectify it

Priya Singhal
  • 1,261
  • 11
  • 16
1

You should be setting the background of the relative layout to be the drawable with radius. Not sure how you named it

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/bakcground_with_radius" >
   ...
</RelativeLayout>
Bojan Kseneman
  • 15,488
  • 2
  • 54
  • 59