2011-02-22 99 views
2

我有一個ListActivity聲明如下機器人,在列表項顯示箭頭圖標

public class SelectSiteActivity extends ListActivity 

然後,我有這樣的

public class SiteListAdapter extends ArrayAdapter<SimpleSiteModel> 

自定義適配器和我的佈局看起來像這樣

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

我怎樣才能讓ImageView一直按到右邊,以便它們都對準垂直然後TextView佔據了該行的其餘部分,因此它們都在中心垂直對齊?

回答

5

我不知道我得到它,但如果你的意思是這樣:

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

那麼你可以使用android:weight=1TextView=0ImageView,並居中文本使用android:gravity="center_horizontal"

+0

它是`android:gravity =「center_vertical」`,但其他一切都像冠軍一樣工作。 – Josh 2011-02-22 18:26:15