Android layout Listview标题格式不设置按钮的格式

Android layout Listview标题格式不设置按钮的格式,android-layout,android-listview,header,Android Layout,Android Listview,Header,在listview中,添加了带有两个按钮的标题。您可以在actionbar的右下方看到按钮“none”和“all”。然后是列表的第一项。按钮应居中,并占用相等的空间 对于页脚(来自不同列表视图的快照),我有一个类似的解决方案。您可以看到列表的底部,然后两个按钮水平分布 以下是标题中的代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schema

在listview中,添加了带有两个按钮的标题。您可以在actionbar的右下方看到按钮“none”和“all”。然后是列表的第一项。按钮应居中,并占用相等的空间

对于页脚(来自不同列表视图的快照),我有一个类似的解决方案。您可以看到列表的底部,然后两个按钮水平分布

以下是标题中的代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" 
android:divider="?android:dividerVertical"
android:weightSum="1"
android:showDividers="middle"
android:orientation="horizontal">


<Button
    android:id="@+id/btn_none"
    style="?android:attr/buttonBarButtonStyle"
    android:layout_height="wrap_content"
    android:layout_width="0dp"
    android:layout_weight="0.5"
    android:layout_marginLeft="16"
    android:layout_marginRight="16"
    android:text="@string/btn_none" />

<Button
    android:id="@+id/btn_all"
    style="?android:attr/buttonBarButtonStyle"
    android:layout_marginLeft="16"
    android:layout_marginRight="16"
    android:layout_height="wrap_content"
    android:layout_width="0dp"
    android:layout_weight="0.5"
    android:text="@string/btn_all" />
</LinearLayout>

我还尝试了相对布局,但它只在页脚中有效,而在页眉中无效。如何调整标题中的按钮

这是页脚代码。它包含用于建立水平线的附加视图

    <LinearLayout
    android:id="@+id/dts_id_button_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="?android:dividerHorizontal"
    android:orientation="vertical"
    android:showDividers="middle" >

    <View
        android:layout_width="match_parent"
        android:layout_height="0dp" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="?android:dividerVertical"
        android:orientation="horizontal"
        android:showDividers="middle"
        android:weightSum="1" >

        <Button
            android:id="@+id/dts_btn_cancel"
            style="?android:attr/buttonBarButtonStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="@string/btn_cancel" />

        <Button
            android:id="@+id/dts_btn_done"
            style="?android:attr/buttonBarButtonStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="0.5"
            android:text="@string/btn_done" />
    </LinearLayout>
</LinearLayout>


删除样式会导致按钮的位置相同-只是现在它们有灰色的windows按钮样式。
我有一个类似的解决方案,用于页脚(来自不同列表视图的快照),它在哪里工作
也发布页脚,以便我们可以发现差异我刚刚添加了代码。按钮上方有一条水平线,我不需要。然而,我刚刚用这一行测试了它,现在按钮正是我需要它们的方式。取出分隔器后,它看起来刚刚好。似乎水平分布需要一个“虚拟”父级才能工作。谢谢你的提示。