我想在 Android 中实现这种布局(我几乎做到了):
这是我制作的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>
它的输出如下所示:
问题是,当我android:layout_alignParentBottom="true"
在第一个单元格中将规则添加到 LinearLayout 以将其推到底部时,它只会拉伸整个页面的整行。没有该规则布局可以正常工作,但这些文本位于顶部,这不是我想要的。可能有一些技巧或规则可以避免这种拉伸,但我完全不知道。请帮忙!