【问题标题】:android - spacing between groups ExpandableListViewandroid - 组之间的间距 ExpandableListView
【发布时间】:2013-01-29 13:46:02
【问题描述】:

我有一个 ExpandableListView,我希望组行之间的空间更小。 dividerHeight 已经设置为零,我不知道那些顶部/底部边距来自哪里。请看下面的截图(请忽略不小心出现的音量控制)

我需要减少行间距,但无法管理。

列表视图:

 <ExpandableListView
    android:id="@android:id/list"
   android:listSelector="@android:color/transparent"
    android:layout_marginTop="80dp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/header"
    android:layout_centerHorizontal="true"
    android:cacheColorHint="@android:color/transparent"
    android:smoothScrollbar="true" >
</ExpandableListView>

在活动中:

            getExpandableListView().setGroupIndicator(null);
    getExpandableListView().setDividerHeight(0);

Grouprow XML:

    <CheckedTextView 
    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="65dp"


android:gravity="center_vertical"
android:text="@string/hello_world"

android:paddingLeft="20dp"
android:textColor="#FFFFFF"
android:textSize="65sp"
android:textStyle="bold" />

更新

grouprow 现在看起来像这样:

 <CheckedTextView 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/hello_world"
android:paddingLeft="20dp"
android:textColor="#FFFFFF"
android:textSize="65sp"
android:textStyle="bold" />

我启用了 listSelector 并发现行高仍然大于实际文本的高度.. 寻找解决方案

【问题讨论】:

  • 不,这是一个CheckedTextView,我把上面的代码贴出来了

标签: android android-listview expandablelistview


【解决方案1】:

您可以在边距属性中使用负值来减少间距。在你的 CheckedTextView 中试试这个:

android:layout_marginTop="-8dp"

【讨论】:

    【解决方案2】:

    您为行数据提供了固定高度,因此会导致问题。

    使用

    android:layout_height="wrap_content"

    相反

    android:layout_height="65dp"

    第二个解决方案@

    删除android:gravity="center_vertical"

    检查并告诉我,否则将删除我的答案。

    【讨论】:

      【解决方案3】:

      以编程方式使用此代码

      expListView.setDividerHeight(0);

      (或)可扩展列表视图分隔线高度值为 0 (xml)

      android:dividerHeight="0dp"

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-18
        • 2021-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多