我尝试在 listView 上使用 marginBottom 在 listView 项目之间腾出空间,但这些项目仍然连接在一起。
甚至可能吗?如果是,是否有具体的方法来做到这一点?
我的代码如下
<LinearLayout
android:id="@+id/alarm_occurences"
android:layout_width="fill_parent"
androidrientation="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"
androidrientation="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>
@Asahi 几乎一针见血,但我只是想为以后可能通过谷歌漂浮在这里的任何人添加一些 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"/>
dividerHeight
。值(value)。它需要一个浮点数和一个单位,例如“10.0sp”。正如@Goofyahead 所指出的,您还可以为此值使用与显示无关的像素(即“10dp”)。
关于android - 如何在Android中设置listView项目之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4984313/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |