布局问题与GridView控件的Andr​​oid中的最后一行 [英] Layout Issue with the last row of GridView in Android

查看:502
本文介绍了布局问题与GridView控件的Andr​​oid中的最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的GridView控件。我每排3个项目。

正如图所示,在视图中的最后一行中只包含一个项目。如果最后一行包含3项,网格视图正常滚动,直到结束。如果最后一排有不少于3项视图不滚动比什么是图片中显示更多。 GridView控件忽略未完全填满行。可能是什么原因呢?

请注意:如果我在末尾加上无形的虚拟物品,以填补​​该行它正常工作

这是我的GridView控件的布局。

 < GridView控件
            机器人:ID =@ + ID / grid_view_featuredtab
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
            机器人:layout_gravity =中心
            机器人:columnWidth时=190dp
            机器人:drawSelectorOnTop =真
            机器人:horizo​​ntalSpacing =3DP
            机器人:listSelector =@彩色/ gridviewlistselector
            机器人:为numColumns =auto_fit
            机器人:paddingRight =4DP
            机器人:stretchMode =spacingWidthUniform
            机器人:verticalSpacing =3DP>


解决方案

截至目前,通过在结尾添加项目哑隐藏的行解决它。

Here is my GridView. I have 3 items in each row.

As shown in the picture, the last row in the view contains only one item. If the last row contains 3 items, the grid view scrolls properly till the end. If the last row has less than 3 items the view doesn't scroll more than what is shown in the picture. GridView ignores the row which is not filled completely. What could be the reason for this?

Note: It works fine if I add invisible dummy items at the end to fill the row.

This is my GridView layout.

 <GridView
            android:id="@+id/grid_view_featuredtab"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:columnWidth="190dp"
            android:drawSelectorOnTop="true"
            android:horizontalSpacing="3dp"
            android:listSelector="@color/gridviewlistselector"
            android:numColumns="auto_fit"
            android:paddingRight="4dp"
            android:stretchMode="spacingWidthUniform"
            android:verticalSpacing="3dp" >

解决方案

As of now, tackled it by adding dummy hidden row of items at the end.

这篇关于布局问题与GridView控件的Andr​​oid中的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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