我在用来显示包含字符串的一个ArrayList的Android应用程序的列表视图,我无法找到的ListView的任何属性,让我到ListView项的文本对齐的,以它的右边,而不是剩下。任何帮助将是巨大的,谢谢。
I have a list view in an Android application used to display an ArrayList containing Strings and I can't find any properties of the ListView that would allow me to align the text of the ListView Items to the right of it instead of the left. Any help would be great, thanks.
答案取决于你到底生成列表。如果使用标准的 ArrayAdapter
,那么你可以使用构造函数:
The answer depends on how exactly do you build the list. If you use the the standard ArrayAdapter
then you could use the constructor:
ArrayAdapter<String>(Context, R.layout.aligned_right, values);
其中, R.layout.aligned_right
是这样的XML布局:
where R.layout.aligned_right
is a xml layout like this:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:paddingLeft="6dip"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="right"/>