如何cenralize最后不均匀排在GridView的机器人?排在、机器人、不均匀、cenralize

2023-09-06 16:14:00 作者:◣U笑過後

我有一个的GridView ,显示字母的照片 发生的事情是,在最后一行中,每次有少无的字母。 最后一行左对齐,它并不好看 所以我想做出最后一行是在市中心, 任何建议

I have a GridView , which displays pictures of alphabets what happens is , every time in the last row there are less no of alphabets. and the last row is left aligned , which doesn't look good so I want make the last row to be in centre, any suggestion

我的的GridView code:

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/grid_view"
    android:layout_width="fill_parent"
    android:layout_marginRight="20dp"
    android:layout_marginTop="20dp"
    android:layout_height="fill_parent"
    android:numColumns="auto_fit"
    android:columnWidth="70dp"
    android:horizontalSpacing="10dp"
    android:verticalSpacing="20dp"
    android:gravity="center"
    android:stretchMode="spacingWidthUniform" >  

</GridView>

推荐答案

我有同样的问题,但我管理这个使用两个GridView的,以第一次GridView控件显示行,除了最后一排,与第二个GridView控件显示的最后一行。这是实现我所需要的最简单的方法。 我还没有找到一个更好的解决方案。期待看到也是一个很好的和简单的方式。

I have the same problem, but I managed this using two gridviews, with first gridview displaying the rows except the last row, with the second gridview displaying the last row. This is the simplest way to achieve what I need. I have not find a better solution. Looking forward to see a nice and simple way also.