Layout Issue with the last row of GridView in Android

邮差的信 提交于 2020-01-03 16:57:35

问题


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" >

回答1:


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



来源:https://stackoverflow.com/questions/14286009/layout-issue-with-the-last-row-of-gridview-in-android

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