我需要在表格布局的左侧和右侧添加两个图像按钮,这是我的屏幕
我想制作这样的屏幕
在表格布局中添加两个图像按钮左右两侧添加此按钮?请帮帮我
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/lightgray"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/buttonlayout"
android:layout_width="fill_parent"
android:layout_height="60sp"
android:background="@drawable/topbar"
android:gravity="left|top"
android:height="60sp"
android:orientation="horizontal" >
<Button
android:id="@+id/last_week"
android:layout_width="54sp"
android:layout_height="60sp"
android:background="@drawable/meenu" />
<ImageButton
android:id="@+id/last_month"
android:layout_width="20sp"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginLeft="10sp"
android:src="@drawable/calendar_left_arrow_selector" >
</ImageButton>
<TextView
android:id="@+id/date_today"
android:layout_width="fill_parent"
android:layout_height="60sp"
android:layout_weight="0.6"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF" >
</TextView>
<ImageButton
android:id="@+id/next_month"
android:layout_width="20sp"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_marginRight="10sp"
android:src="@drawable/calendar_right_arrow_selector" >
</ImageButton>
<Button
android:id="@+id/next_week"
android:layout_width="54sp"
android:layout_height="60sp"
android:background="@drawable/plus" />
</LinearLayout>
<TableLayout
android:id="@+id/table_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:stretchColumns="0,1,2,3,4,5,6">
<TableRow
android:paddingBottom="12dp"
android:background="#FEE5AC"
>
<TextView
android:id="@+id/sun"
android:gravity="center"
android:text="@string/sunday"
android:textColor="#ff0000"/>
<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="#ff0000"/>
</TableRow>
<TableRow
android:paddingBottom="12dp">
<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="#ff0000" >
</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="#000000" >
</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="#000000" >
</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="#000000" >
</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="#000000" >
</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="#000000" >
</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="#ff0000" >
</Button>
</TableRow>
</TableLayout>
</LinearLayout>
答案 0 :(得分:0)
将表格布局包裹在水平LinearLayout
中,并使用布局权重使表格在占用按钮宽度后占用所有剩余空间:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton . . . (left image button attributes) />
<TableLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" . . . >
. . .
</TableLayout>
<ImageButton . . . (right image button attributes) />
</LinearLayout>