Eiad Deeb
Eiad Deeb

Reputation: 187

how to make text align in android listview from right to left?

please I want to make my listview's items start from right to left like this how can I do it?

like this image

Upvotes: 2

Views: 3721

Answers (3)

Bahaa Hany
Bahaa Hany

Reputation: 754

Add the below to the Layout

android:layoutDirection="rtl"

Upvotes: 1

golkarm
golkarm

Reputation: 1014

You can use a custom list and edit items to any way that you want.

http://www.learn2crack.com/2013/10/android-custom-listview-images-text-example.html

Abow link is your answer but in list_single.xml you must right:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <!-- you can add same margin and other thing to improve view -->  
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true" >

</RelativeLayout>

If it was useful mark it accepted and if NOT tell as comment to get more information.

Upvotes: 0

Illegal Argument
Illegal Argument

Reputation: 10338

For that you need to provide a custom textview for you adapter. Something like this should do the trick:

listview.setAdapter(new ArrayAdapter(context,R.layout.textview,new String[]{"one","2","3"}));

Then in your textview.xml referenced by above adapter put a textview and set its android:gravity="right".

Upvotes: 0

Related Questions