0

我需要在表格布局的左侧和右侧添加两个图像按钮这是我的屏幕

当前屏幕

我想做这样的屏幕

想要的画面

在表格布局的左侧和右侧添加两个图像按钮 ho 添加此按钮??请帮帮我

<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>
4

1 回答 1

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>
于 2013-07-28T21:37:51.250 回答