How to set gridview column width in android?

I use gridview in android and I want to set the first column width, but I could not. while I am trying to find the answer to the problem, I came face to face with a comment, as you can see below. My question is, is the description below really true?

All columns in the GridView are the same size. On Saturday, May 23, 2009 at 9:25 pm, Solid wrote:

I'm having trouble controlling the size of the columns in my grid view. The first column is only 3-4 characters, and the remaining 4 columns are 5-8 characters. For some reason, all columns are the same width, leaving a huge amount of space after the first column and wrapping text inside others. Is there a way I can set the width of individual columns as a grid? In an ideal world, gridview will work as an html table where smaller columns are reduced to, if necessary, data and large columns are expanded. Any ideas to be helpful.

+6
source share
3 answers

You seem to be better off using TableLayout

+4
source

You can directly write in your layout resource file.

android:columnWidth="100dp" 

https://developer.android.com/guide/topics/ui/layout/gridview.html

0
source

try this, it will help you

 <?xml version="1.0" encoding="utf-8"?> <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnWidth="90dp" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:stretchMode="columnWidth" android:gravity="center" /> 
-2
source

Source: https://habr.com/ru/post/893351/


All Articles