Search code examples
androidgridviewandroid-gridviewarabicright-to-left

android grid view place items from right to left


I'm working on an android application with arabic version.

In one of the interfaces, I have gridView. So to display items in the correct order, I have to display items in the GridView from the right to the left (and of corse from the top to the bottom). To do that, I tried to add these attributes in the GridView :

android:gravity="right"
android:layout_gravity="right"

Unfortunately, items still displayed from the left to the right.

any idea to do it in the right way ?


Solution

  • You can achieve this by this ugly workaround:

    1. add this line to your GridView in XML:

      android:rotationY="180"

    2. also add the same line to your GridView item in XML:

      android:rotationY="180"

    In total it gives you rotation by 360° so it looks like GridView places items from right to left.