在Android的网格视图中,网格视图的行之间存在额外的空间。我没有向网格视图添加任何空间。
这是我的XML文件。
这是我的XML文件。
<GridView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:horizontalSpacing="5px"
android:numColumns="3"
android:columnWidth="50dip"
android:verticalSpacing="0dip"
android:gravity="center"
/>
同时,用于向网格视图添加视图的另一个XML是:
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/singlePhoto"
android:layout_gravity="top"
android:layout_width="145dip"
android:layout_height="145dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
>
</ImageView>
在适配器类中,代码如下:
if(mView == null){
mView = mLayoutInflater.inflate(R.layout.newsgridthumbpic, null);
}
ImageView mImage = (ImageView)mView.findViewById(R.id.singlePhoto);
PhotoGridInfoSet mInfo = (PhotoGridInfoSet)details.get(position);
if(mImage != null){
mImage.setTag(mInfo.getPhotoThumbNailString());
mImage.setVerticalScrollBarEnabled(true);
mImage.setVerticalFadingEdgeEnabled(true);
}
}!
表格视图中的空格是在行之间。我在代码中没有添加任何空格,但仍然存在垂直间距。我不知道为什么表格视图行之间会有空格。在hdpi设备/模拟器中不会出现这个问题,但在mdpi和ldpi设备/模拟器中会出现。