Android:图片按钮未对齐

时间:2012-12-04 07:06:07

标签: android button

我希望我的图像按钮放在scree的rt侧面。但它没有显示出来。请看代码。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<TableLayout
    android:id="@+id/tableLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center_vertical" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Date of Birth:" />

        <Button
            android:id="@+id/dateButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:text="Select date" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Manual labour" />

        <EditText
            android:id="@+id/ed1"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:inputType="number" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Gender :" />

        <RadioGroup
            android:id="@+id/radioSex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <RadioButton
                android:id="@+id/radioMale"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:checked="true"
                android:text="Male" />

            <RadioButton
                android:id="@+id/radioFemale"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Female" />
        </RadioGroup>
    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Occupation" />

        <Spinner
            android:id="@+id/spinner1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:entries="@array/occuaption_arrays"
            android:prompt="@string/occupation_prompt" />
    </TableRow>

    <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Monthly Income" />

        <Spinner
            android:id="@+id/spinner2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:entries="@array/income_arrays"
            android:prompt="@string/income_prompt" />
    </TableRow>
</TableLayout>



    <ImageButton
        android:id="@+id/next"
        android:layout_height="50dp"
        android:layout_width="50dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:contentDescription="dfg"
        android:src="@drawable/next"
        android:visibility="visible"/>

我尝试使用RelativeLayout作为父级并添加属性android:layout_alignParentRight =“true”和android:layout_alignParentBottom =“true”

我的形象非常大。这可能是个问题吗?

1 个答案:

答案 0 :(得分:0)

您已将match-parent设置为TableLayout的宽度和高度。所以TableLayout重叠了ImageButton

使用以下代码...

 android:layout_width="match_parent"
 android:layout_height="wrap-content"
相关问题