安卓:在GridView控件减少列之间的空间

编程入门 行业动态 更新时间:2024-10-07 12:27:43
本文介绍了安卓:在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="schemas.android/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控件减少列之间的空间

本文发布于:2023-11-30 15:33:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   空间   GridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!