Dip*_*ali 18 android android-gridview
在android网格视图中,网格视图的行之间有额外的空间.我没有在gridview中添加任何空间.
这是我的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"
/>
Run Code Online (Sandbox Code Playgroud)
以及为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>
Run Code Online (Sandbox Code Playgroud)
在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);
}
}!
Run Code Online (Sandbox Code Playgroud)
空间位于gridview行之间.我没有在代码中的任何地方添加任何空格仍然有垂直间距.我不能理解为什么gridview行之间有空间.此空间未出现在hdpi设备/模拟器中.此问题出在mdpi和ldpi设备/模拟器中.
Dip*_*ali 41
我得到了解决这个问题的方法.
要解决这个问题,我需要在我的xml文件中添加1行
android:adjustViewBounds="true"
Run Code Online (Sandbox Code Playgroud)
并在添加此之后.这个空间现在没有出现
归档时间: |
|
查看次数: |
26854 次 |
最近记录: |