使用自定义适配器在可扩展列表视图上手动缩进子视图

Manualy indent child view on exapandable listivew with custom adapter

是否可以手动缩进可折叠列表视图的子视图?我正在使用具有组布局和子布局的自定义适配器如何在组选择上缩进子视图?

<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="@dimen/drawer_content_padding"/>
<!-- The navigation drawer -->

!-- The main content view -->
<RelativeLayout
    android:id="@+id/mainContent"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<!-- The navigation drawer -->
<RelativeLayout
    android:layout_width="@dimen/drawer_size"
    android:layout_height="match_parent"
    android:id="@+id/container"
    android:layout_gravity="start">

    <ExpandableListView
        android:id="@+id/nav_drawer"
        android:layout_width="280dp"
        android:padding="15dp"
        android:layout_height="wrap_content"
        android:choiceMode="singleChoice"
        android:scrollbars="none"
        android:background="#fff"
        android:groupIndicator="@android:color/transparent"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

</RelativeLayout>

您可以通过自定义适配器完成此操作。只需向您的子视图添加填充

convertView.setPadding(20,0,0,0); // left, top, right, bottom

我实际上通过缩进字符串中的菜单项名称解决了这个问题

即缩进

      &#160;&#160;&#160;&#160;

在菜单名称前会缩进。