如何在android中制作线性布局的页脚

如何在android中制作线性布局的页脚,android,android-linearlayout,Android,Android Linearlayout,我想使页脚在线性布局,但这种布局我也使用片段标记。有人知道如何在此布局中设置页脚吗?我看过很多例子,但都没有成功 我的XML:- <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_h

我想使页脚在线性布局,但这种布局我也使用片段标记。有人知道如何在此布局中设置页脚吗?我看过很多例子,但都没有成功

我的XML:-

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

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
    <fragment
        android:id="@+id/list_Fragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.ListFragment" >
    </fragment>

    <fragment
        android:id="@+id/detail_Fragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.DetailFragment" >
    </fragment>
</LinearLayout>
    <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#eee">
        <TextView
            android:id="@+id/cart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/filter"
            android:textSize="20sp"
            android:padding="10dp"
            android:textColor="#FF0000"
            android:layout_alignParentBottom="true"/>
        <TextView
            android:id="@+id/buy_now"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/clear_all"
            android:padding="10dp"
            android:textSize="20sp"
            android:textColor="#FF0000"
            android:layout_alignParentBottom="true"/>
    </RelativeLayout>
    <Space
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"/>
</LinearLayout>
我是android开发新手,请告诉我!提前谢谢

我编辑了您的XML

让我知道这是你的要求吗

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <fragment
            android:id="@+id/list_Fragment"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.ListFragment" >
        </fragment>

        <fragment
            android:id="@+id/detail_Fragment"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="2"
            class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.DetailFragment" >
        </fragment>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#eee" >

        <TextView
            android:id="@+id/cart"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:padding="10dp"
            android:text="Filter"
            android:textColor="#FF0000"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/buy_now"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="center"
            android:padding="10dp"
            android:text="Clear All"
            android:textColor="#FF0000"
            android:textSize="20sp" />
    </LinearLayout>

</LinearLayout>

我不知道你对碎片中的布局权重做了什么,但这会让你接近你想要的我假设你想让这两个碎片并排显示?:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

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

        <fragment
            android:id="@+id/list_Fragment"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
      class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.ListFragment" />

        <fragment
            android:id="@+id/detail_Fragment"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
           class="shoppingmazza.android.catalyst.com.shoppingmazza.activity.DetailFragment" />

    </LinearLayout

    <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#eee">

        <TextView
            android:id="@+id/cart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/filter"
            android:textSize="20sp"
            android:padding="10dp"
            android:textColor="#FF0000"
            android:layout_alignParentBottom="true"/>


        <TextView
            android:id="@+id/buy_now"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/clear_all"
            android:padding="10dp"
            android:textSize="20sp"
            android:textColor="#FF0000"
            android:layout_alignParentBottom="true"/>

        </RelativeLayout>

</LinearLayout>

您可以使用另一个LinearLayout作为页脚,页脚只引用listview。您可以给出一个示例吗?您是否确实需要一个在xml上创建LinearLayout的示例,您已经发布了一个示例!我不明白你在问什么。请先清楚地描述您的需求。或者发布您的需求的图像。现在在不需要页脚的片段中,您可以使用android:id=@+id/footer将可见性设置为消失或不可见。您可以告诉我如何对齐android的右侧:text=@string/filter检查编辑。您现在可以根据需要设置重力。我在页脚的centerTextViews中设置了它:如果您使用的是layout_weight,则layout_width或layout_height应为0dp,这是未知的,因为您在页脚的线性布局中也缺少方向