我正在研究一个简单的待办事项列表应用程序。我使用ExpandableListView
来显示任务。出于某种原因,我一直在组和子视图之间出现一个奇怪的空间。我试图在xml中设置divider height为0dp
,但它不会改变任何东西。为ExpandableListView
可扩展列表视图 - 子视图和组视图之间的空间
我的XML代码:
<ExpandableListView android:id="@+id/myList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/addTask"/>
编辑:
子视图的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="130dp"
android:background="#ff0000">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/displayDetails"
android:text="@string/detailsChild"
android:textColor="#ffffff"/>
父视图的xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#424242"
android:layout_height="130dp"
android:id="@+id/layoutCustom">
<View android:layout_width="fill_parent" android:layout_height="30dp"
android:background="#FFFFFF"
android:id="@+id/SpaceView"
/>
<TextView
android:layout_below="@id/SpaceView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:text="@string/nameofcourse"
android:id="@+id/course" android:layout_margin="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/date"
android:id="@+id/date"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:layout_below="@+id/course"
android:layout_marginLeft="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/date"
android:textColor="#FFFFFF"
android:textSize="16sp"
android:text="@string/typeoftask"
android:layout_marginLeft="10dp"
android:id="@+id/type" android:layout_marginTop="10dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/delete"
android:textSize="26sp"
android:textColor="#FE2E2E"
android:id="@+id/delete"
android:minWidth="20dp"
android:minHeight="0dp"
android:focusable="false"
android:layout_below="@+id/SpaceView" android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<ImageButton android:layout_width="40dp" android:layout_height="50dp"
android:id="@+id/mainEdit"
android:src="@drawable/edit2"
android:focusable="false"
android:layout_below="@+id/date"
android:layout_alignParentRight="true"/>
</RelativeLayout>
谢谢你们,有一个很好的一周!
可以添加'儿童和组视图xml'文件? –
编辑帖子并添加 – baki1995
它可能是页眉/页脚分隔线吗?尝试在ExpandableListView中设置android:headerDividersEnabled = false并查看是否有效。 – Dave