繁体   English   中英

FragmentDialog中的按钮样式

[英]Button style in FragmentDialog

我创建了一个简单的评级对话框,扩展了FragmentDialog 结果如下:

在此输入图像描述

但我希望获得一个样式的按钮,就像在android中使用的典型对话框中使用的那样

在此输入图像描述

我怎样才能获得这个结果?

 <View
        android:id="@+id/divider"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_above="@+id/submit_layout"
        android:layout_alignParentBottom="false"
        android:background="?android:attr/listDivider" />

    <LinearLayout
        android:id="@+id/submit_layout"
        style="@style/ButtonBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:descendantFocusability="beforeDescendants"
        android:gravity="center_vertical"
        android:minHeight="48dp"
        android:orientation="vertical" >

        <Button
            android:id="@+id/reload_btn"
            style="@style/ButtonBarButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/selectable_item_background"
            android:minHeight="48dp"
            android:text="Submit" />
    </LinearLayout>

和“selectable_item_background.xml”:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/item_pressed" android:state_pressed="true" />
    <item android:drawable="@drawable/item_focused" android:state_focused="true" />
    <item android:drawable="@drawable/item_focused" android:state_selected="true" />
    <item android:drawable="@android:color/transparent" />
</selector>

将STYLE_NO_FRAME提供给DialogFragment的方法setStyle(int,int)并使用TextViews而不是自定义布局中的两个按钮应该可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM