GridView:删除水平和垂直空间之间的空间 [英] GridView : Removing spaces between horizontal and vertical spaces
问题描述
网格视图的项
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/iconGrid"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"/>
网格视图布局
<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:listSelector="#80AD3B6D"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:stretchMode="columnWidth"
android:numColumns="3">
</GridView>
由于某些原因,网格视图之间仍然有空格,我将尝试所有可能的解决方案,但仍然无法做到.图像(项目)的每一面都以某种方式存在间隙.而我所有人想要的是使所有图像之间保持无间隙.即instagram网格视图(靠在一起)
For some reasons, the grid view still have spaces between them, and i'll try all the possible solution, but still unable to do it. Somehow there's a gap on each side of the image(item). And i all want is to make all the images with no space between them. i.e instagram grid view(close together)
提前谢谢
解决方案
因此,我已经弄清楚如何更改整个内容以使其之间没有间隙.和Gridview.xml仍然保持不变.
So i already figure how to change the whole thing to make it NO GAP in between. and Gridview.xml still remain the same.
这将是items.xml:
This will be the items.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:background="#000000"
android:layout_height="wrap_content">
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/iconGrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleType="fitXY"
android:adjustViewBounds="true"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="right|bottom"
android:padding="2dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/like"
android:layout_width="15dp"
android:layout_height="15dp"
android:src="@drawable/hwhite"
android:visibility="invisible" />
<TextView
android:id="@+id/num"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:text="121"
android:textColor="#FFFFFF"
android:visibility="invisible" />
</LinearLayout>
</FrameLayout>
</LinearLayout>
推荐答案
请尝试删除以下属性:
android:stretchMode="columnWidth"
This problem has been encountered there, so please give a look as well: Which stretchMode to use in GridView on android
这篇关于GridView:删除水平和垂直空间之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!