How do I align listview text to the right in Android?

I have a list view in the Android application for displaying ArrayList containing string. I can't find any properties of listview. These properties allow me to align the text of listview item to its right instead of left. Any help will be great, thank you

resolvent:

The answer depends on how you build the list. If you use the standard arrayadapter, you can use the constructor:

ArrayAdapter<String>(Context, R.layout.aligned_right, values);

Where r.layout.aligned_ Right is an 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"/>

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>