Manualy indent child view on exapandable listivew with custom adapter

400 Views Asked by At

Is it possible to manually indent the child view of a collapsible list view? I'm using a custom adapter with group layout and child layout how do i indent child view on group selection?

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

2

There are 2 best solutions below

0
On BEST ANSWER

I actually solved this by indenting the menu item names in the strings

ie indenting

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

before a menu name will indent it.

0
On

You can do it from your custom adapter. Just add padding to your child view

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