16
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ListViewのdividerに余白をつける

Last updated at Posted at 2015-01-17

ListViewのdividerに余白をつける方法です。

2015-01-17_01_35_14.png

dividerのdrawableを作成

res/drawable/にdivider用のxmlを作成します。

res/drawable/divider.xml
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetLeft="16dp"
    android:insetRight="16dp">

    <shape>
        <solid android:color="#EEEEEE" />
        <corners android:radius="1dp" />
    </shape>

</inset>

ListViewのdivider属性にセット

作成したxmlを、ListViewのdivider属性にセットします。

<ListView
    android:divider="@drawable/divider"
    android:dividerHeight="1dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

参考 : How to assign padding to Listview item divider line

16
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?