Forum Xamarin.Android

How to force Arabic text in a dialog box to be flush left

RonNYCRonNYC Member ✭✭✭

I have a dialog box which displays a list of languages like this:

        var dialogView = LayoutInflater.Inflate(Resource.Layout.list_view, null);
        Android.App.AlertDialog alertDialog;

        listview = dialogView.FindViewById<ListView>(Resource.Id.listview);

        var items = new string[] { "English", "español", "中文(s)", "中文(t)", "日本語", "हिन्दी", 
        "français", "Deutsche", "русский", "عربى" };
        //  var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, 
        items);
        var adapter = new ArrayAdapter<string>(this, Resource.Layout.list_item, items);

But when this is displayed, all the items are flush left except the last one (which is "Arabic" in arabic).

Is there a way to force it to the left?

Thanks.

RON

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    But when this is displayed, all the items are flush left except the last one (which is "Arabic" in arabic).

    Try to set android:textDirection to ltr in list_view.xml to make the text display from left side.

    <ListView
        android:id="@+id/listview"
        android:textDirection="ltr"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    

Sign In or Register to comment.