自定义日历应填充屏幕

时间:2012-09-28 23:27:18

标签: java android calendar

我在我的应用中使用this custom calendar。我希望日历日期应该填满整个屏幕,而不是包装内容,这使得应用程序在底部有很多空白区域。如何使日历填满屏幕的底部(当月份为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>

1 个答案:

答案 0 :(得分: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);


}