<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="75dp" android:orientation="horizontal" android:background="@drawable/gridpaper_row"> <ImageView android:id="@+id/liImage" android:tag="togglebutton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginRight="5dp" android:layout_gravity="center_vertical" android:onClick="statusGroupClickHandler" android:src="@drawable/checkmarkuncheckedimage58x54" /> <TextView android:id="@+id/liName" style="@style/MediumBlackBoldText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight=".5" android:layout_marginRight="35dp" android:layout_gravity="center_vertical" android:gravity="left|center_vertical" /> </LinearLayout>
Sunday, April 15, 2012
Text Wrapping Expandable List Adapters
Expandable Lists allow you to have a two tiered list consisting of a list of groups and their attached children. I've used this type of adapter on a couple of projects and it's quite easy. The Groups and children can have custom layouts just like a normal list adapter. This allows you to style both the groups and the children. The group adapter automatically displays an open and close arrow icons on the right side, although the graphic used varies from device to device or Android build level to build level. On a recent project, the customer had a really long group name that wrapped behind the right hand side open and close icons. This was an easy fix though via adding a right side margin to my group's title text field as in the xml below.