在TableLayout中对齐底部会拉伸行

时间:2014-01-14 10:02:00

标签: android android-layout xml-layout

我想在Android中实现这种布局(我差不多做了): enter image description here

这是我制作的xml:

<?xml version="1.0" encoding="utf-8"?>

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000">

    <TableRow
        android:layout_weight="1"
        android:clipChildren="false"
        >

        <RelativeLayout
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:layout_weight="1"
            android:background="@drawable/book"
            android:layout_margin="10sp"
            android:clipToPadding="false"
            >

            <TextView
                style="@style/round_badge"
                android:text="34"
                />

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_alignParentBottom="true"
             >

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="This is the very cool title"
                    android:textSize="50sp"
                    android:textStyle="bold"
                    android:textColor="#FFFFFF"
                    android:layout_marginBottom="10sp"
                />

                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="And this is some very nice description about content"
                    android:textColor="#FFFFFF"
                    android:textSize="30sp" />
            </LinearLayout>

        </RelativeLayout>

    </TableRow>

    <TableRow
        android:layout_weight="1"
        android:clipChildren="false">

        <RelativeLayout
            style="@style/single_book_narrow"
            android:background="@drawable/book"
            android:layout_height="fill_parent"
            android:layout_width="0dp"
            android:layout_weight="0.5"
            android:layout_margin="10sp"
            android:clipToPadding="false"
            >

            <TextView
                style="@style/round_badge"
                android:text="34"
                />

        </RelativeLayout>

        <RelativeLayout
            style="@style/single_book_narrow"
            android:background="@drawable/book"
            android:layout_height="fill_parent"
            android:layout_width="0dp"
            android:layout_weight="0.5"
            android:layout_margin="10sp"
            android:clipToPadding="false"
            >

            <TextView
                style="@style/round_badge"
                android:text="10"
                />

        </RelativeLayout>

    </TableRow>

</TableLayout>

它的输出看起来像那样:

enter image description here

问题在于,当我将android:layout_alignParentBottom="true"规则添加到第一个单元格中的LinearLayout以将其推到底部时,它只是拉伸整个页面的整行。没有这个规则布局工作正常但这些文本在顶部,这不是我想要的东西。可能有一些技巧或规则来避免拉伸,但我完全没有意识到这一点。请帮忙!

0 个答案:

没有答案