listView で marginBottom を使用して listView 項目間にスペースを作ろうとしましたが、それでも項目は一緒に接続されています。
それは本当に可能ですか? もし可能であれば、それを実行する特定の方法はありますか?
私のコードは以下の通りです
<LinearLayout
android:id="@+id/alarm_occurences"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
android:background="#EEEEFF"
xmlns:android="http://schemas.android.com/apk/res/android">
<ListView
android:id="@+id/occurences"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
私のカスタムリスト項目:
<com.android.alarm.listItems.AlarmListItem
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/alarm_item_background"
android:layout_marginBottom="10dp"
>
<CheckedTextView
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:textSize="20sp"
android:textStyle="bold"
android:typeface="serif"
android:padding="10dp"
/>
</com.android.alarm.listItems.AlarmListItem>
この場合、リスト項目間にスペースを作るにはどうすればよいですか?
ベストアンサー1
@Asahi はほぼ的を射ていますが、後で Google 経由でここにたどり着く人のために、少し XML を追加したいと思いました。
<ListView android:id="@+id/MyListView"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp"/>
何らかの理由で、「10」、「10.0」、「10sp」などの値はすべて Android によって拒否されますdividerHeight
。Android では、「10.0sp」などの浮動小数点数と単位が必要です。@Goofyahead が指摘しているように、この値にはディスプレイに依存しないピクセル (つまり、「10dp」) を使用することもできます。