0

我用 CheckedTextView 作为项目创建了 GridView。

这是我在 XML 中的 Gridview

<GridView
    android:id="@+id/grid_1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"                
    android:numColumns="auto_fit"
    android:horizontalSpacing="5dip"
    android:verticalSpacing="5dip"                
    android:gravity="center"                       
    android:choiceMode="multipleChoice"/>

这里是 XML 中的 GridView 项

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/checkedTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"        
    android:textColor="@color/gray_color"    
    android:background="@drawable/shape_rectangle"/>

但是它连续显示两个项目,每个项目都显示有额外的空间,如下所示 在此处输入图像描述

如何避免 GridView 中每个项目的额外空间?

4

1 回答 1

0

尝试在项目的宽度和高度中使用 match_parent,不确定是什么问题,但我也遇到了这个问题,告诉我这是否解决了它,否则我会查看我的旧项目并为您提供另一个解决方案

于 2013-10-30T09:35:15.793 回答