7

I had a TitleBar(#lotTopTitleBar) in the LinearLayout, and the LinearLayout will be full size of the screen, now, I want show a View(#lotFloatView) reference the TitleBar below, but both view aren't at the same level container, so the layout_below doesn't work, if anybody know about that, please help me a change.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical">

        <LinearLayout android:id="@+id/lotTopTitleBar"
                      android:layout_width="match_parent"
                      android:layout_height="50dp">
        </LinearLayout>

        <LinearLayout android:layout_width="match_parent"
                      android:layout_height="0dp"
                      android:layout_weight="1">
        </LinearLayout>

        <LinearLayout android:layout_width="match_parent"
                      android:layout_height="50dp">
        </LinearLayout>

    </LinearLayout>

    <LinearLayout android:id="@+id/lotFloatView"
                  android:layout_width="120dp"
                  android:layout_height="wrap_content"
                  android:layout_below="@id/lotTopTitleBar">
        <Button android:layout_width="match_parent"
                android:layout_height="60dp"
                android:background="@null" />
        <Button android:layout_width="match_parent"
                android:layout_height="60dp"
                android:background="@null" />
    </LinearLayout>

</RelativeLayout>
4

1 回答 1

5

我认为您可以通过使用相对布局而不是线性布局来实现这一点。我没有测试过它,但它应该可以工作。

    <RelativeLayout android:layout_width="match_parent"
              android:layout_height="match_parent"
              >

       <LinearLayout android:id="@+id/lotTopTitleBar"
                  android:layout_width="match_parent"
                  android:layout_height="50dp">
    </LinearLayout>
    <LinearLayout android:id="@+id/lotFloatView"
              android:layout_width="120dp"
              android:layout_height="wrap_content"
              android:layout_below="@id/lotTopTitleBar">
    <Button android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="@null" />
    <Button android:layout_width="match_parent"
            android:layout_height="60dp"
            android:background="@null" />
</LinearLayout>

    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="0dp"
                  android:layout_below="@id/lotTopTitleBar"
                  android:id="@+id/lotLL"
                  android:layout_weight="1">
    </LinearLayout>

    <LinearLayout android:layout_width="match_parent"
                  android:layout_below="@id/lotLL"
                  android:layout_height="50dp">
    </LinearLayout>

</RelativeLayout >

编辑

    <LinearLayout android:layout_width="match_parent"
                  android:layout_below="@id/lotLL"
                  android:layout_alignParentBottom="true"
                  android:id="@+id/lotLastLL"
                  android:layout_height="50dp">
    </LinearLayout>

    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_below="@id/lotTopTitleBar"
                  android:layout_above="@id/lotLastLL"
                  android:id="@+id/lotLL"
                  >
    </LinearLayout>
于 2013-07-15T05:20:19.870 回答