2016-05-16 76 views
1

我正在研究一个简单的待办事项列表应用程序。我使用ExpandableListView来显示任务。出于某种原因,我一直在组和子视图之间出现一个奇怪的空间。我试图在xml中设置divider height为0dp,但它不会改变任何东西。为ExpandableListView可扩展列表视图 - 子视图和组视图之间的空间

screenshot of the space

我的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> 

谢谢你们,有一个很好的一周!

+0

可以添加'儿童和组视图xml'文件? –

+0

编辑帖子并添加 – baki1995

+0

它可能是页眉/页脚分隔线吗?尝试在ExpandableListView中设置android:headerDividersEnabled = false并查看是否有效。 – Dave

回答

0

我没有得到实际上是什么这个原因,当我想你的layout文件,但它确实表明了divider即使dividerHeight设置为0dp,但一些自定义的颜色设置为android:divider和设置dividerHeight0dp确实删除了white空间。我在这里粘贴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"/> 
+0

作品!非常感谢! – baki1995

+0

很高兴听到:) –