0

I want to achieve that kind of layout in Android (which I almost did): enter image description here

Here is the xml I've produced:

<?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>

And its output look like that:

enter image description here

The problem is that when I've added android:layout_alignParentBottom="true" rule to the LinearLayout in the first cell to push it to the bottom it just stretched the whole row for the whole page. Without that rule layout works fine but those texts are on the top and this is not something I want. Probably there some trick or rule to avoid that stretching, but I'm totally not aware of it. Please help!

lukaleli
  • 3,427
  • 3
  • 22
  • 32
  • 1
    you dont need TableLayout for that. Simply use LinearLayout with weights. – waqaslam Jan 14 '14 at 10:06
  • Try also setting the `weightSum` on the `TableLayout`: `android:weightSum="2"`. Your layout is very inefficient. – user Jan 14 '14 at 10:06

0 Answers0