Android:ExpandableListview中的不同分隔符高度

Cha*_*lie 3 height android parent-child expandablelistview

我在我的应用程序中有一个自定义可扩展,我希望标题(5dp)和子(1dp)的分隔符高度不同.我怎么办?这是我的代码:

bus_info.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ExpandableListView
    android:id="@+id/expandableBus"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="3dp"
    android:divider="@drawable/expandable_borde_padre"
    android:childDivider="@drawable/expandable_borde_hijo"
    android:groupIndicator="@drawable/expandable"
    android:scrollbars="none"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

expandable.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:drawable="@drawable/expandable_abajo" android:state_empty="true"/>
      <item android:drawable="@drawable/expandable_arriba" android:state_expanded="true"/>
      <item android:drawable="@drawable/expandable_abajo" />
</selector>
Run Code Online (Sandbox Code Playgroud)

expandable_borde_padre.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
      android:shape="rectangle">
     <solid android:color="@color/negro"/>
     <size android:height="1dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

expandable_borde_hijo.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle">
    <solid android:color="@color/blanco"/>
    <size android:height="1dp"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

如果我在expandable_borde_padre中更改为5dp也会更改子项

expandable_hijo.java

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="55dip"
android:orientation="vertical" 
android:background="#000000">

<TextView
    android:id="@+id/lblListItem"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="14sp"
    android:paddingTop="5dp"
    android:paddingBottom="5dp"
    android:textColor="#FFFFFF"/>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

expandable_padre.java

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fondoExpandablePadre"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" 
android:background="#000000">


<TextView
    android:id="@+id/lblListHeader"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="1dp"
    android:textSize="15sp"
    android:textColor="#000000" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

小智 7

将divider和childdivider都设置为null.使用自定义分隔符的自定义标题和子视图.

例如:

对于标题:

< TextView>

< /TextView>

< View android:height:"5dp">
< /View>
Run Code Online (Sandbox Code Playgroud)

对于孩子:

< TextView>

< /TextView>

< View android:height:"1dp">
< /View>
Run Code Online (Sandbox Code Playgroud)