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 ?
In addition to the above answer:
Ideally, if you want to make it rtl aware, so only rtl in locales where it should be:
You can also make it follow the containing layout
device local language is English : enter image description here
device local language is parsian : enter image description here
add this line to your GridView in XML:
Based on traninho's answer:
do the following:
On your GridActivity, delete this:
Now, go to your gridAdapter and add onClickListener to the gridImage so, your code should look like the following:
This will handle clicks normally on your GridView images.
Wish that helps :)
As Nibha Jain said, its right. Also you need to add a property "android:layoutAnimation" to the GridView xml as below.
and also you need to define an animation file with "android:direction" attribute, which actually renders your items from right to left or any supported direction.
The layout_grid_right_to_left.xml file inside anim folder
the @anim/fade is as below
Its just my preferences. Please add/remove attributes that suites your needs. Play with it.
You can achieve this by this ugly workaround:
add this line to your GridView in XML:
android:rotationY="180"
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.