在 android 网格视图中,网格视图的行之间有额外的空间。我没有向网格视图添加任何空间。
这是我的 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"
/>
将视图添加到 gridview 的 imageview 的另一个 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>
在Adapter类中代码是
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);
}
}!
该空间位于 gridview 的行之间。我没有在代码中的任何位置添加任何空格仍然存在垂直间距。我无法理解为什么 gridview 行之间有空格。此空间未出现在 hdpi 设备/模拟器中。此问题出现在 mdpi 和 ldpi 设备/模拟器中。
我得到了这个问题的解决方案。
为了解决这个问题,我需要在我的 xml 文件中添加 1 行
android:adjustViewBounds="true"
添加后。该空间现在没有出现
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)