Milad Faridnia
Milad Faridnia

Reputation: 9477

Place items from right to left in gridLayout

I have a GridLayout in one of my layouts. I want to place items from right to left, Which means I want to have cell(1,1) in top right of my layout. I have tested these codes in GridView so far:

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?

Upvotes: 3

Views: 3015

Answers (2)

Nadir Belhaj
Nadir Belhaj

Reputation: 12063

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"

Upvotes: 10

Ricardo Oyarzun
Ricardo Oyarzun

Reputation: 71

You should use in the viewgroup

android:layoutDirection="locale"

and then in whatever item you have inside set the gravity like this:

android:gravity="start" # or end 

I know this is an old question a just wanted to complete a more accurate answer for people finding this post

Upvotes: 6

Related Questions