Android List Item: TextView on left, Image on right

i'm creating a custom list item in and android list view. it's very simple, it has a textview on the left and an image on the right. the image should align all the way right, and the text view should take up all the space on the left. problem is, i can get the image to show up, but it pushes left. if i set the textview width to fill_parent, the image disappears. here's my layout:

<?xml version="1.0" encoding="utf-8" ?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" 
              android:layout_width="fill_parent" android:layout_height="50px" android:layout_gravity="center_vertical">
  <!-- item -->
  <TextView android:id="@+id/txtItem" android:gravity="center_vertical" android:textSize="20px" android:layout_width="fill_parent" 
            android:layout_height="fill_parent"/>

  <!-- disclosure image -->
  <ImageView android:layout_gravity="right|center_vertical" android:src="@drawable/common_icon_arrow_disclosure" 
              android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</LinearLayout>

i've also tried a relative layout, but the same thing happens. what am i doing wrong?


EDIT: for clarification, this is what i'm trying to accomplish:

alt text

i want the text field to take up the whole left area, and the image to be on the right, unscaled, vertically centered.

11
задан bryan costanich 5 December 2010 в 23:06
поделиться