Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 356
ghost rider3 Avatar asked Jul 24 '13 09:07

ghost rider3


2 Answers

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.

like image 101
traninho Avatar answered Nov 19 '22 23:11

traninho


add this line to your GridView in XML:

android:layoutDirection="rtl"
like image 7
Pooya Hayati Avatar answered Nov 19 '22 23:11

Pooya Hayati