我正在创建一个像这个图像的日历
但我的屏幕看起来像这样
我是如何完全不是所有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>
答案 0 :(得分:0)
您实际上不需要使用Button
作为按钮。我使用TextView
应用所有布局设置,因为我需要将其android:clickable
设置为true
并将其视为常规按钮。工作和好处是,无论您的应用程序运行的Android版本如何,如果看起来像你喜欢(因为Button
在2.x和3.x +上看起来不同)
答案 1 :(得分:-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>