Josh
Josh

Reputation: 16567

android, show arrow icon in List item

I have a ListActivity declared like this

public class SelectSiteActivity extends ListActivity

Then, I have a custom adapter like this

public class SiteListAdapter extends ArrayAdapter<SimpleSiteModel>

and my layout looks like this

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:background="#ffffff">

    <TextView
        android:id="@+id/siteName"
        android:textColor="#000000"
        android:text="Site Name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16sp" />

    <ImageView
        android:id="@+id/siteListMoreImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/expander_ic_minimized" />
</LinearLayout>

How do I get the ImageView to be pressed all the way over to the right so they are all aligned vertically and then the TextView takes up the rest of the row and so they are both aligned vertically in the center?

Upvotes: 2

Views: 2980

Answers (1)

bigstones
bigstones

Reputation: 15267

I'm not sure I got it, but if you mean something like:

+------------+---+
|   blabla   | o |
+------------+---+
|     bla    | o |
+------------+---+
!   .......  !...!

then you could use android:weight=1 for the TextView and =0 for the ImageView, and to center the text use android:gravity="center_horizontal".

Upvotes: 5

Related Questions