Java 可展开列表视图-子视图和组视图之间的空间
我正在开发一个简单的待办事项列表应用程序。我使用Java 可展开列表视图-子视图和组视图之间的空间,java,android,xml,widget,expandablelistview,Java,Android,Xml,Widget,Expandablelistview,我正在开发一个简单的待办事项列表应用程序。我使用ExpandableListView显示任务。出于某种原因,我总是在组视图和子视图之间找到一个奇怪的空间。我尝试在xml中将分隔符高度设置为0dp,但它不会改变任何东西 可扩展列表视图的我的xml代码: <ExpandableListView android:id="@+id/myList" android:layout_width="wrap_content" android:layout_hei
ExpandableListView
显示任务。出于某种原因,我总是在组视图和子视图之间找到一个奇怪的空间。我尝试在xml中将分隔符高度设置为0dp
,但它不会改变任何东西
可扩展列表视图的我的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 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:
<?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 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>
谢谢大家,祝你们一周愉快 我不知道这到底是什么原因,当我尝试你的
布局文件时,它确实显示了分隔符
,即使分隔符灯
设置为0dp,但是将一些自定义颜色设置为android:divider
并将dividerHeight
设置为0dp确实删除了白色
空间。我正在这里粘贴xml
,您可以自己检查一下,看看是否有帮助
<ExpandableListView android:id="@+id/myList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#000" <!-- Use any color or drawable -->
android:dividerHeight="0dp"
android:layout_below="@+id/addTask"/>
android:dividerHeight=“0dp”
android:layout_下方=“@+id/addTask”/
我不知道这到底是什么原因,当我尝试你的布局
文件时,它确实显示了分隔符
,即使分隔符高度
设置为0dp,但是将一些自定义颜色设置为android:divider并将dividerHeight
设置为0dp确实删除了白色
空间。我正在这里粘贴xml
,您可以自己检查一下,看看是否有帮助
<ExpandableListView android:id="@+id/myList"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#000" <!-- Use any color or drawable -->
android:dividerHeight="0dp"
android:layout_below="@+id/addTask"/>
android:dividerHeight=“0dp”
android:layout_下方=“@+id/addTask”/
您可以为子视图和组视图添加xml
文件吗?编辑帖子并添加它是否可以作为页眉/页脚分隔符?试着在ExpandableListView中设置android:headerDividersEnabled=false,看看是否有效。试过了。没有更改任何内容..:(@baki1995你解决了这个问题吗?你能为子视图和组视图添加xml
文件吗?编辑帖子并添加了页眉/页脚分隔符吗?尝试在ExpandableListView中设置android:headerDividersEnabled=false,看看是否有效。只是尝试了。没有更改任何内容。(@baki1995你解决了这个问题吗?