See attached screenshot where I am attempting to reduce the space between the columns in my GridView.
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>
I am creating the ImageViews in my code from a Bitmap. However, I am not specifying any padding or spacing or otherwise.
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 :
Thanks
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"
or set the horizontal and vertical spacing in xml for grid
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
Remove Gravity attribute and use the following mode
android:stretchMode="NONE"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With