【问题标题】:How to set divider height for childview in expandable listview如何在可扩展列表视图中为子视图设置分隔线高度
【发布时间】:2014-07-08 10:48:43
【问题描述】:

如何在可扩展列表视图中为子视图和父视图设置不同的分隔高度值

这是我的代码

可扩展列表视图.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000" >

<ExpandableListView
    android:id="@+id/left_drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="20dp"
    android:background="#000000"
    android:choiceMode="singleChoice"
    android:divider="@null"
    android:dividerHeight="3dp"
    android:footerDividersEnabled="true"
    android:padding="5dp"
    android:scrollbars="none" />

expandable_child.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:orientation="vertical"
tools:context=".Main_Navigation" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:background="#E5E5E5"
    android:gravity="center_vertical"
    android:textColor="#000000" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/border_two"
        android:padding="5dp"
        android:text="AAAAA"
        android:textSize="14sp" />
</LinearLayout>

Expandable_header.xml

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@drawable/fag_dropdown" (image)
android:gravity="center_vertical"
android:padding="5dp"
android:layout_marginTop="5dp"
android:textColor="#FFFFFF"
android:text="aaaaa"
android:textSize="15sp"

/>

border_two.xml

<?xml version="1.0" encoding="UTF-8"?>
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
    android:width="1dp"
    android:color="#A4A4A4"/>
<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="0dp"
    android:topLeftRadius="0dp"
    android:topRightRadius="0dp" />

那么,如何为 header 和 child 设置不同的分隔符高度

【问题讨论】:

  • 你试过 expView.setDividerHeight(2); 吗? ,请发布你的代码
  • 我试过了,但我需要两个不同的分隔线高度用于父视图和子视图,这是我的问题

标签: android user-interface parent-child


【解决方案1】:

试试这个:android:dividerHeight="50dp"

【讨论】:

  • 将为组和孩子设置高度,只需要孩子。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-31
  • 2015-09-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多