0

在此处输入图像描述

我在下面给出了我的布局 xml。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:stretchColumns="1" >


    <TableRow>

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:src="@drawable/no_image" />

        <TableLayout
            android:layout_width="match_parent"
            android:layout_gravity="left"
            android:stretchColumns="0" >

            <TableRow>


                <EditText
                    android:id="@+id/editText1"
                    android:layout_width="match_parent"
                    android:layout_weight="1"
                    android:background="@drawable/backwithborder"
                    android:ems="5" />
            </TableRow>

            <TableRow android:layout_height="match_parent" >

                <EditText
                    android:id="@+id/editText1"
                    android:layout_weight="1" 
                    android:layout_height="35dip"
                    android:background="@drawable/backwithborder" />

                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_gravity="right"
                    android:src="@drawable/ic_menu_down" />
            </TableRow>
        </TableLayout>
    </TableRow>

    <View
        android:layout_height="2dip"
        android:background="@color/list_seperator" />

    <TableRow>

        <Button
            android:id="@+id/xBtnContacts"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Pick Contacts" />
    </TableRow>

    <View
        android:layout_height="2dip"
        android:background="@color/list_seperator" />

</TableLayout>
4

3 回答 3

0

尝试移动重力并将宽度和高度设置为 fill_parent

        android:id="@+id/imageView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="right"
        android:src="@drawable/no_image" />
于 2012-06-12T08:18:12.390 回答
0

图像和编辑文本之间的间距是由于“选择联系人”,如表格布局中一行的宽度取决于其他......(尝试将宽度 40dp 赋予按钮以进行测试)

我会建议使用线性布局和相对布局来制作这个 UI....

于 2012-06-12T08:18:33.657 回答
0

试试这样的东西

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:src="@drawable/ic_launcher" />

<TableLayout
    android:id="@+id/table"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/imageView1" >

    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:ems="5" />
    </TableRow>

    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="match_parent" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="35dip"
            android:layout_weight="1" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:src="@android:drawable/ic_menu_add" />
    </TableRow>
</TableLayout>

<Button
    android:id="@+id/xBtnContacts"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/table"
    android:text="Pick Contacts" />
<View
    android:layout_height="2dip"
    android:layout_width="fill_parent"
    android:layout_below="@id/xBtnContacts"
    android:background="#ff0000"/>

</RelativeLayout>
于 2012-06-12T08:37:21.790 回答