Place items from right to left in gridLayout

丶灬走出姿态 提交于 2019-12-11 03:08:28

问题


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?


回答1:


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"



回答2:


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



来源:https://stackoverflow.com/questions/25845714/place-items-from-right-to-left-in-gridlayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!