-1

我正在创建一个像这张图片一样的日历 在此处输入图像描述

但我的屏幕看起来像这样

在此处输入图像描述

我如何不完全 7 个按钮如何只显示 4 个按钮 我将如何使布局与示例图像相同

<LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal" >

  <ImageView
     android:id="@+id/last_week"
     android:layout_width="50sp"
     android:layout_height="fill_parent"
     android:background="#F2F2F2"
     android:src="@drawable/barrowleft2" >
  </ImageView>

  <TableLayout
    android:id="@+id/table_layout"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="center_horizontal"
    android:stretchColumns="0,1,2,3,4,5,6" >

    <TableRow
        android:background="#F2F2F2"
        android:paddingBottom="12dp" >

        <TextView
            android:id="@+id/sun"
            android:gravity="center"
            android:text="@string/sunday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/mon"
            android:gravity="center"
            android:text="@string/monday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/tue"
            android:gravity="center"
            android:text="@string/tuesday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/wed"
            android:gravity="center"
            android:text="@string/wednesday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/thur"
            android:gravity="center"
            android:text="@string/thursday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/fri"
            android:gravity="center"
            android:text="@string/friday"
            android:textColor="#000000" />

        <TextView
            android:id="@+id/sat"
            android:gravity="center"
            android:text="@string/saturday"
            android:textColor="#000000" />
    </TableRow>

    <TableRow>

        <Button
            android:id="@+id/e00"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e02"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e04"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e05"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>

        <Button
            android:id="@+id/e06"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/calendar_button_selector"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#D9DBD7" >
        </Button>
     </TableRow>
  </TableLayout>

  <ImageView
     android:id="@+id/next_week"
     android:layout_width="50sp"
     android:layout_height="fill_parent"
     android:background="#F2F2F2"
     android:src="@drawable/barrrow113" >
  </ImageView>

</LinearLayout>
4

2 回答 2

0

你真的不需要使用Button你的按钮。我会使用TextView应用所有布局设置,因为我需要将其设置android:clickabletrue并视为常规按钮。将起作用,并且好处是无论您的应用程序在哪个 android 版本上运行,如果看起来像您一样(Button在 2.x 和 3.x+ 上看起来不同)

于 2013-08-23T08:46:46.310 回答
-1

试试下面的代码..但是它不是实现日历的正确方法..你应该使用 GridView

<Button
    android:id="@+id/e06"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@drawable/calendar_button_selector"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="#D9DBD7" >
</Button>
于 2013-08-23T08:32:30.370 回答