Center elements in GridView

前端 未结 9 1328
挽巷
挽巷 2020-12-29 19:44

I have GridView with 6 images in 2 columns. I want to display this 6 images in the middle of the screen. I set gravity properties to center but this center elements only hor

9条回答
  •  无人及你
    2020-12-29 20:40

    I found that you just have the gridlayout wrap content on height and width.

    android:layout_centerHorizontal="true"
    

    It will center itself for the size it needs but if you have it matching the parent. You are technically centering it based with a lot of parent empty space offsetting your children.

提交回复
热议问题