2011-07-13 16 views
0

我基本上是同樣的事情ListView row styling - left aligned text, and right-aligned icon:在它listItems中的列表視圖是右對齊:如何在不重疊滾動條的情況下顯示Android右對齊的ListItem數據?

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 
    <TextView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:text="Name" 
     android:id="@+id/list_item_name" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_alignParentLeft="true" 
     > 
    </TextView> 
    <TextView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:text="0x0 0s" 
     android:id="@+id/list_item_value" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_alignParentRight="true" 
     > 
    </TextView> 
</RelativeLayout> 

,它工作正常..。除該list_item_value文本由滾動條遮蔽。名稱和值之間有很多空白區域,將所有值左移一點就沒問題,但我也不知道該怎麼做。

回答

2

嘗試設置android:layout_marginRightlist_item_value。嘗試一個像10dp左右的值 - 只是爲了感受一下,然後相應地進行調整。

+0

謝謝,這是有效的;有沒有辦法將它設置爲等於滾動條的寬度再加上幾個dp? – pjz

+0

如果這不起作用,填充也可能會有所幫助。另外,請記住,從2.2開始,滾動條並不總是可見的。 – dmon

相關問題