安卓:在GridView控件减少列之间的空间 [英] Android: Reduce space between columns in GridView

查看:271
本文介绍了安卓:在GridView控件减少列之间的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

附见截图在这里,我试图降低我的GridView中列之间的空间。

See attached screenshot where I am attempting to reduce the space between the columns in my GridView.

我的main.xml如下:

My main.xml is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<GridView 
android:id="@+id/gridview"
android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:stretchMode="columnWidth"
android:gravity="center"
/>
<LinearLayout 
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
    <ImageView 
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/logo"/>
    <TextView
    android:text="@string/game_score"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>

我在创建从位图我的code中的ImageViews。不过,我不指定任何填充或间隔或以其他方式。

I am creating the ImageViews in my code from a Bitmap. However, I am not specifying any padding or spacing or otherwise.

我怎样才能减少列之间的空间?我试过了各种关于两个GridView和ImageViews但没有运气

How can I reduce this space between columns? I've tried a variety of settings on both GridViews and ImageViews but with no luck

图片

Image is :

感谢

推荐答案

尝试修复电网XML文件所需的列数,并设置stretchMode为columnWidth时

try to fix the number of columns needed in xml file for grid and set stretchMode as columnwidth

android:numColumns="3"
android:columnWidth="60dp"
android:stretchMode="columnWidth"

或设置水平和垂直间距以xml电网

or set the horizontal and vertical spacing in xml for grid

android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"

这篇关于安卓:在GridView控件减少列之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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