请参阅随附的屏幕截图,其中我试图减少 GridView 中列之间的空间。
我的main.xml如下:
<?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>
我正在我的代码中从位图创建 ImageView。但是,我没有指定任何填充或间距或其他方式。
如何减少列之间的空间?我在 GridViews 和 ImageViews 上尝试了各种设置,但没有成功
Image is :
Thanks
尝试修复网格的 xml 文件中所需的列数并将stretchMode设置为columnwidth
android:numColumns="3"
android:columnWidth="60dp"
android:stretchMode="columnWidth"
或者在xml中设置网格的水平和垂直间距
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)