0

我在我的应用程序中使用这个自定义日历。我希望日历日期应该填满整个屏幕,而不是包装内容,这使得应用程序在底部有很多空白。如何让日历填满屏幕底部(当月有 4 或 5 周时相应调整)?

这是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"
    android:background="@drawable/bg">

    <ImageView
        android:id="@+id/calendarToJournalButton"
        android:src="@drawable/add_entry_button_selector"
        android:gravity="left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingBottom="10dip">
    </ImageView>


    <Button
        android:id="@+id/selectedDayMonthYear"
        android:textColor="#FFFFFF"
        android:layout_gravity="center"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:background="@drawable/calendar_top_header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </Button>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:id="@+id/prevMonth"
            android:src="@drawable/calendar_left_arrow_selector"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </ImageView>
        <Button
            android:id="@+id/currentMonth"
            android:layout_weight="0.6"
            android:textColor="#FFFFFF"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:background="@drawable/calendar_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </Button>
        <ImageView
            android:id="@+id/nextMonth"
            android:src="@drawable/calendar_right_arrow_selector"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
        </ImageView>
    </LinearLayout>

    <LinearLayout
        android:layout_gravity="center"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <ImageView
            android:id="@+id/calendarheader"
            android:src="@drawable/blue_bg_with_text"
            android:layout_gravity="center"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
        </ImageView>
    </LinearLayout>


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

</LinearLayout>
4

1 回答 1

0

这对我有用:

public int ROW_NUMBER = 5;

public View getView(int position, View convertView, ViewGroup parent)
{
 AbsListView.LayoutParams param = new AbsListView.LayoutParams(
                        android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                        gridview.getHeight()/ROW_NUMBER);
 convertView.setLayoutParams(param);


}
于 2012-10-10T22:19:44.110 回答