如何在Android中删除网格视图的行之间的空间 [英] How to remove the space between rows of grid view in android

查看:51
本文介绍了如何在Android中删除网格视图的行之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android网格视图中,网格视图的行之间有多余的空间.我没有在gridview中添加任何空间.

In android grid view there is extra space between the rows of grid view. I am not adding any space to the 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"
                />

和将view添加到gridview的imageview的其他xml是

and the other xml for the imageview which is adding view to the gridview is

        <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类中,代码为

In Adapter class the code is

        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设备/仿真器中存在此问题.

The space is between the rows of gridview. I have not added any space anywhere in the code Still the there is vertical spacing.I am not able understand why there is space in between gridview rows. This space is not appearing in the hdpi device/emulator. This problem is in the mdpi and ldpi devices/emulator.

推荐答案

我已经找到了解决此问题的方法.

I got the solution for this problem.

要解决此问题,我需要在我的xml文件中添加1行

To solve this i need to add 1 line in my xml file

android:adjustViewBounds="true"

,然后添加此内容.该空间现在没有出现

and after adding this. the space is not appearing now

这篇关于如何在Android中删除网格视图的行之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆