Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridview : How to fill entire space with text view

I am creating a calendar using GridView (6 row * 8 column). Each of the cells inside this matrix (6*8) is a TextView (which I create dynamically in my program).

The issue I am facing is, the 6*8 matrix is not filling the entire space available for GridView

I would like to to have the 6*8 matrix take the entire space in GridView rather than leaving some blank space b/w the matrix and the next TextView. Can some one help me on this.

Given below is the xml layout of the Gridview

<?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"
android:layout_weight="1" >

    <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:numColumns="8"
        android:verticalSpacing="10dp"
        android:horizontalSpacing="10dp"
        android:gravity="center"
        android:layout_weight="1"
            />


    <TextView  
            android:id="@+id/id_worked"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="Result 1 ->"
        android:layout_weight="0"
        android:textSize="20sp"
        />
</LinearLayout>

Grid View

like image 526
Raj Avatar asked Nov 14 '22 18:11

Raj


1 Answers

Remove the

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

from the GridView element. That shoudld reduce the spacing.

Edit: Using LinearLayout you can do this.

<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1"
android:weightSum="6">
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
    <LinearLayout android:layout_width="fill_parent"
         android:layout_height="fill_parent" android:layout_weight="1">items here</LinearLayout>
</LinearLayout>
like image 150
Ronnie Avatar answered Dec 09 '22 09:12

Ronnie