Milad Milad - 5 months ago 44
Android Question

Place items from right to left in gridLayout

I am developing an app with persian version. I have a GridLayout in one of my layouts.
I want to place items from right to left in that layout, Which means I want to have cell(1,1) in top right of my layout.
I have tested:

1-

android:gravity="right"


and

android:layout_gravity="right"


but it doesn't work.

2- I also tested

android:layoutDirection="rtl"


and it doesn't work too.
how can I place items from right to left?

Answer

Here is a workaround

add this line to your GridView in XML:

android:rotationY="180"

then add the same line to your GridView item in XML:

android:rotationY="180"