0

In the above code the calendar that is in the middle is actually a gridview. As you can see it is not covering the whole space and there is a black background that is visible. How do i stretch the columns or rows so that there is not black space present.

the xml for the gridview is as follows:

<GridView android:id="@+id/calendar" 
          android:numColumns="7"
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content">

</GridView>

thank you in advance.enter image description here

Edit: Update twoenter image description here

There is still some spaces in right of calendar.How to remove it?

Edit: Update 3

<LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:layout_above="@id/menuoptions">
    <RelativeLayout style="@style/widescreen"
        android:background="@drawable/top_header">
        <ImageView style="@style/compactview" android:src="@drawable/banner1"
            android:layout_marginLeft="5dip" android:id="@+id/bannerview"
            android:layout_centerVertical="true"></ImageView>
        <ImageView style="@style/compactview" android:src="@drawable/logo"
            android:layout_marginRight="20dip" android:layout_alignParentRight="true"></ImageView>
    </RelativeLayout>
    <LinearLayout style="@style/widescreen"
        android:background="#ffffff" android:orientation="vertical">
        <LinearLayout style="@style/widescreen"
            android:background="#ffffff" android:orientation="horizontal">
            <Button style="@style/compactview" android:background="@drawable/kalenderhover"
                android:layout_marginLeft="3dip" android:onClick="calendarButtonClicked"
                android:id="@+id/calendarbutton" android:layout_marginTop="6dip"
                android:layout_marginBottom="5dip"></Button>
            <Button style="@style/compactview" android:background="@drawable/tag"
                android:onClick="dayButtonClicked" android:id="@+id/daybutton"
                android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
            <Button style="@style/compactview" android:background="@drawable/monat"
                android:id="@+id/monthbutton" android:onClick="monthButtonClicked"
                android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
            <Button style="@style/compactview" android:background="@drawable/jahr"
                android:id="@+id/yearbutton" android:onClick="yearButtonClicked"
                android:layout_marginTop="6dip" android:layout_marginBottom="5dip"></Button>
            <Spinner style="@style/compactview" android:id="@+id/category_name"
                android:background="@drawable/categoriahover"
                android:layout_marginLeft="5dip" android:layout_marginTop="7dip"
                android:layout_marginBottom="4dip"></Spinner>
        </LinearLayout>
    </LinearLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="@drawable/calenderheaderwithoutarrow"
        android:id="@+id/calendarheader">

        <ImageView android:id="@+id/prevMonth" android:src="@drawable/left_arrow"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_marginLeft="10dip" android:layout_marginTop="5dip">
        </ImageView>
        <Button android:id="@+id/currentMonth" android:layout_weight="0.6"
            android:textColor="#FFFFFF" android:textAppearance="?android:attr/textAppearanceMedium"
            android:background="@android:color/transparent"
            android:layout_width="wrap_content" android:layout_height="wrap_content">
        </Button>
        <ImageView android:layout_marginRight="10dip" android:id="@+id/nextMonth"
            android:src="@drawable/right_arrow" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_marginTop="5dip">
        </ImageView>
    </LinearLayout>
    <ViewFlipper android:id="@+id/mainflipper" style="@style/compactview">
        <LinearLayout android:id="@+id/calendartab" style="@style/compactview"
            android:orientation="vertical">
            <GridView android:id="@+id/calendar" android:numColumns="7"
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:listSelector="@drawable/datecell"
                android:layout_marginRight="0dip" android:paddingRight="0dip">
            </GridView>
            <ListView android:id="@+id/eventlist" style="@style/widescreen">
            </ListView>
        </LinearLayout>
        <LinearLayout android:id="@+id/daytab" style="@style/compactview"
            android:orientation="vertical">
            <LinearLayout style="@style/compactview"
                android:background="@drawable/calenderheader">
                <EditText style="@style/compactview" android:id="@+id/searchkeyword"
                    android:hint="Suche" android:inputType="text"
                    android:layout_marginLeft="5dip" android:minWidth="200dip">
                </EditText>
                <Button android:onClick="searchingButtonClicked"
                    android:background="@drawable/abbrechen"
                    android:layout_marginLeft="5dip" style="@style/compactview"
                    android:layout_gravity="center_vertical|right"></Button>
            </LinearLayout>
            <ListView android:id="@+id/daylisting" style="@style/compactview"></ListView>
        </LinearLayout>
        <LinearLayout android:id="@+id/monthtab" style="@style/compactview"
            android:orientation="vertical">
            <LinearLayout style="@style/compactview"
                android:background="@drawable/calenderheader">
                <EditText style="@style/compactview" android:id="@+id/searchkeyword"
                    android:hint="Suche" android:inputType="text"
                    android:layout_marginLeft="5dip" android:minWidth="200dip">
                </EditText>
                <Button android:onClick="searchingButtonClicked"
                    android:background="@drawable/abbrechen"
                    android:layout_marginLeft="5dip" style="@style/compactview"
                    android:layout_gravity="center_vertical|right"></Button>
            </LinearLayout>
            <ListView android:id="@+id/monthlisting" style="@style/compactview"></ListView>
        </LinearLayout>
        <LinearLayout android:id="@+id/yeartab" style="@style/compactview"
            android:orientation="vertical">
            <LinearLayout style="@style/compactview"
                android:background="@drawable/calenderheader">
                <EditText style="@style/compactview" android:id="@+id/searchkeyword"
                    android:hint="Suche" android:inputType="text"
                    android:layout_marginLeft="5dip" android:minWidth="200dip">
                </EditText>
                <Button android:onClick="searchingButtonClicked"
                    android:background="@drawable/abbrechen"
                    android:layout_marginLeft="5dip" style="@style/compactview"
                    android:layout_gravity="center_vertical|right"></Button>
            </LinearLayout>
            <ListView android:id="@+id/yearlisting" style="@style/compactview"></ListView>
        </LinearLayout>
    </ViewFlipper>
</LinearLayout>
</RelativeLayout>

Compact view is width and height set to wrap_content

ManthanDalal
  • 1,063
  • 2
  • 20
  • 45

1 Answers1

0

Please see the Update2 part of this answer.
@Shekhar had the same problem, and in that update you can find

  • the reason why the padding appears,
  • the solution how to avoid it.

I hope you can work it out!

Update:
You might also want to specify the strechMode for your GridView so the columns to stretch equally within the parent layout:

<GridView [...] android:stretchMode="columnWidth" />
Community
  • 1
  • 1
rekaszeru
  • 19,130
  • 7
  • 59
  • 73
  • Please see my update two.I did what you say and how it works. – ManthanDalal May 13 '11 at 06:36
  • Based on the first screenshot, the right margin was initially wider than the others, so I'd suggest you to set the `GridView`'s right margin, or the right padding of the view containing the `GridView` to 0. Without the whole layout code it is difficult to figure out where the problem could be. It may also lye in your item renderer (if it has a margin set). – rekaszeru May 13 '11 at 06:41
  • I have not added in margin in the render I am adding in xml layout – ManthanDalal May 13 '11 at 06:48
  • You must set your `GridView`'s `layout_width` to `fill_parent` (as the `ListView` beneath). – rekaszeru May 13 '11 at 06:55
  • the width is set to fill_parent. also the right padding and margin are set to 0. – user590849 May 13 '11 at 06:56
  • Right, but your `ViewFlipper` and `LinearLayout` (parents of your `GridView` are still set to `layout_width="wrap_content"`, which causes this problem. Their width should be set to fill their parent's view, and let only their height be compact (`wrap_content`). – rekaszeru May 13 '11 at 07:02
  • tried it. made the width of all its parents to fill_parent. Not only its parents but the parents of its parents also (its grand parents :-)) to fill_parent...ie from the rootview leading to the gridview..all the views have width as fill_parent. still no change. – ManthanDalal May 13 '11 at 07:15
  • I'd like compile your layout code, and debug it to see where the problem lies. For this I would need the styles you use, and the `@drawable/datecell`. Could you please share them? Thank you! – rekaszeru May 13 '11 at 07:20
  • If you can't provide more information, we cannot guess where your problem may root. I've set up a dummy activity displaying your layout, and there are no gaps around the `GridView`, so the issue must be somewhere else in your code. Please see my update and give it a try. – rekaszeru May 14 '11 at 06:46