如何cenralize最后不均匀排在GridView的机器人? [英] How to cenralize last uneven row in GridView in android?

查看:128
本文介绍了如何cenralize最后不均匀排在GridView的机器人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的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.

这篇关于如何cenralize最后不均匀排在GridView的机器人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆