My Android ListView item layout looks terrible
Posted
by
jnylen
on Stack Overflow
See other posts from Stack Overflow
or by jnylen
Published on 2011-01-08T03:36:43Z
Indexed on
2011/01/08
3:53 UTC
Read the original article
Hit count: 506
I wanted to create a layout like the CyanogenMod call log in that there is a list item and a call button on the left which gets focus separately (screenshot). Instead, I get this mess.
Here's my code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:minHeight="?android:attr/listPreferredItemHeight"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="4dip"
>
<DontPressWithParentImageView android:id="@+id/play_icon"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingLeft="14dip"
android:paddingRight="14dip"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:src="@drawable/sym_play"
android:background="@drawable/play_background"
/>
<View android:id="@+id/divider"
android:layout_width="1px"
android:layout_height="fill_parent"
android:layout_marginTop="5dip"
android:layout_marginBottom="5dip"
android:layout_toLeftOf="@id/play_icon"
android:layout_marginLeft="2dip"
android:background="@drawable/divider_vertical_dark"
/>
<TextView android:id="@+id/file_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="8dip"
android:layout_marginTop="-10dip"
android:layout_marginLeft="10dip"
android:layout_alignWithParentIfMissing="true"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold"
/>
<TextView android:id="@+id/file_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="@id/file_info"
android:layout_alignWithParentIfMissing="true"
android:layout_marginBottom="-10dip"
android:layout_marginLeft="4dip"
android:textAppearance="?android:attr/textAppearanceLarge"
android:singleLine="true"
android:ellipsize="marquee"
android:gravity="center_vertical"
/>
</RelativeLayout>
For reference, the code I started with is here and here, and the source to DontPressWithParentImageView
is here (but as you can see from my screenshot, that part is working).
What am I doing wrong?
© Stack Overflow or respective owner