Apply margins(padding) to listview selector in Android

32 views Asked by At

How to set margins(padding) to listview default selector?

Default selector

Something what I want

So, I wanna save default appeance with animations, just add margins(padding). And I use appcompat-v7 library(AppCompatActivity, etc.)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="60pt"
    android:orientation="horizontal"
    android:paddingLeft="12dp"
    android:paddingRight="12dp" >

    <TextView
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Name"/>
    <TextView
        android:id="@+id/item2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Surname"/>

</LinearLayout>
1

There are 1 answers

0
Surender Kumar On

Can you try below layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="20dp">

    <TextView
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Name"/>
    <TextView
        android:id="@+id/item2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Surname"/>

</LinearLayout>