Search code examples
androidgridviewutf8-decode

android gridview arabic letter displayed in opposite direction


I am working on a simple android game that contains two gridview: one for letters and the other for words,these letters and words are saved in the database, I am trying to change the language of the letters and words from english to arabic and it worked fine but the problem is they are displayed from left to right. I solved this problem by adding this code to both gridviews in the xml file:

android:rotationY="180"  //gridview letters

android:rotationY="180"   //gridview words

but then I faced another problem which is the letters and words are displayed in opposite direction, for example this arabic letter should be displayed like this:

enter image description here

but it is displayed like this:

enter image description here

any help will be appreciated.

this is my gridview code:

  <GridView
        android:id="@+id/gridviewLetters"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"   
        android:divider="@android:color/transparent"
        android:horizontalSpacing="2dp"
        android:listSelector="@android:color/transparent"
        android:numColumns="7"
        android:columnWidth="60dp"
        android:verticalSpacing="7dip"
        android:rotationY="180"  >
    </GridView>


    <GridView
        android:id="@+id/gridviewWords"
        android:layout_width="54dp"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"   
        android:listSelector="@android:color/transparent"
        android:stretchMode="columnWidth"
        android:rotationY="180"  >
    </GridView>

Solution

  • if you want to display text R to L than no need to rotate it,

    you have to just a line in manifest.xml in application tag

    <application ...
             android:supportsRtl="true"
             ... >
    . . .
    </application>