我试图用marginBottom在列表视图,使ListView项之间的空间,但仍是项目连接在一起。
I tried to use marginBottom on the listView to make space between listView Item, but still the items are attached together.
它甚至有可能吗?如果是的话,有没有具体的办法做到这一点?
Is it even possible? If yes, is there a specific way to do it?
我的code低于
<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>
我的自定义列表项:
My custom List item:
<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>
我怎样才能让列表项之间的间距在这种情况下?
How can I make spacing between list items in this case?
推荐答案
@Asahi pretty的多击中了要害,但我只是想补充一点XML的任何人都可能通过谷歌漂浮在晚一点
@Asahi pretty much hit the nail on the head, but I just wanted to add a bit of XML for anyone maybe floating in here later via google:
<ListView android:id="@+id/MyListView"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp"/>
由于某些原因,价值观,如10,10.0和10SP一切都是由机器人为 dividerHeight
值拒绝。它想要一个浮点数和一个单元,如10.0sp。作为@Goofyahead笔记,你也可以使用显示器无关像素此值(即10dp)。
For some reason, values such as "10", "10.0", and "10sp" all are rejected by Android for the dividerHeight
value. It wants a floating point number and a unit, such as "10.0sp". As @Goofyahead notes, you can also use display-independent pixels for this value (ie, "10dp").
相关推荐
最新文章