如何将TableLayout与另一个TableLayout的底部对齐?

时间:2015-08-06 10:25:36

标签: android xml button

我正在努力实现“电话拨号器”外观,但似乎无法让它工作。这是我的代码:

<TableLayout
    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" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="splitzerjoke.zickens.com.calcuhorario.nuevoHorario"
    style="?android:attr/buttonBarStyle" >

    <TextView
        android:textStyle="bold"
        android:textSize="32sp"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:id="@+id/nuevoHorario_lunes"
        android:text="@string/nuevoHorario_lunes"
        />

    <View
        android:layout_marginTop="10dp"
        android:layout_height="2dp"
        android:background="#999999"
        />
    <!-- Éstas son las filas para seleccionar las horas ocupadas -->

    <TableLayout
        android:layout_gravity="bottom"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:stretchColumns="0,1,2"
        >

    <TableRow>

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora1_lunes_texto"
            android:id="@+id/hora1_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora2_lunes_texto"
            android:id="@+id/hora2_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora3_lunes_texto"
            android:id="@+id/hora3_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

    </TableRow>

    <TableRow>
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora4_lunes_texto"
            android:id="@+id/hora4_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora5_lunes_texto"
            android:id="@+id/hora5_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora6_lunes_texto"
            android:id="@+id/hora6_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />
    </TableRow>

    <TableRow>
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora7_lunes_texto"
            android:id="@+id/hora7_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora8_lunes_texto"
            android:id="@+id/hora8_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora9_lunes_texto"
            android:id="@+id/hora9_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />
    </TableRow>

    <TableRow>
        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora10_lunes_texto"
            android:id="@+id/hora10_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora11_lunes_texto"
            android:id="@+id/hora11_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />

        <Button
            style="?android:attr/buttonBarButtonStyle"
            android:text="@string/hora12_lunes_texto"
            android:id="@+id/hora12_lunes"
            android:layout_height="50dp"
            android:layout_width="wrap_content" />
    </TableRow>

        <TableRow>

            <Button
                style="?android:attr/buttonBarButtonStyle"
                android:layout_column="2"
                android:layout_height="50dp"
                android:layout_width="wrap_content"
                android:id="@+id/siguiente_lunes"
                android:text="@string/siguiente_lunes_texto"
                />

        </TableRow>

    </TableLayout>

</TableLayout>

预览看起来像这样: Preview

我想要做的是将所有这些蓝色按钮向下拖动,以便显示“¡Listo!”按钮。触及底部,所有其他人都遵循它;实现这一点真的很令人沮丧,任何帮助都将受到赞赏。

1 个答案:

答案 0 :(得分:0)

使用TableLayout作为根布局,并在android:alignParentBottom="true"中执行:uploads#myuploads