Search code examples
androidlistviewandroid-listviewmargin

Margin of ListView row is not visible


I have a ListView with custom row style with rounded coreners. I want to set a margin for ListView rows. but when I'm trying to set margins of rows, nothing is visible to me.
This is my row style:

<?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="@color/orange" />

    <corners
        android:bottomLeftRadius="3dp"
        android:bottomRightRadius="3dp"
        android:topLeftRadius="3dp"
        android:topRightRadius="3dp" />

    <gradient
        android:angle="-90"
        android:endColor="@color/bright_orange"
        android:startColor="@color/bright_orange" />

</shape>

this is rows layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/newsRow"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:background="@drawable/message_row_style"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/txtTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:padding="5dp" />

</LinearLayout>

How should I set the margin between ListView rows?


Solution

  • You should play with some attributes of your list view like dividerHeight. You can find more information on this thread.