1

我正在为我的按钮栏使用 ?android:attr/buttonBarStyle 和 ?android:attr/buttonBarButtonStyle 。

这是我的代码:

    <LinearLayout
        android:id="@+id/label_edit_dialog_buttonbar"
        style="?android:attr/buttonBarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/label_edit_dialog_name_edittext"
        android:layout_marginTop="8dp"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/label_edit_dialog_save_button"
            style="?android:attr/buttonBarButtonStyle"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="@string/save" />

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

这是我得到的结果:

在此处输入图像描述

我希望在我的按钮栏和其他视图之间看到一个分隔线,但我没有看到。我在使用 AlertDialog 时看到了顶部 Divider - 我检查了 AlertDialog xml 布局,发现 AlertDialog 也使用了 buttonBarStyle。有人有什么想法吗?谢谢!

这是开发设置:Eclipse + Nexus 4 Simulator + Min API is 14+

4

1 回答 1

0

ButtonBarStyle 不(据我所知)提供分隔线。要创建这样的分隔线,您需要将它们作为视图添加到布局中(有关更多信息,请参阅此问题)。

于 2014-10-16T18:54:46.117 回答