android - 如何将 DialogFragment 上的按钮设置为平面样式?

标签 android user-interface android-dialogfragment

也许我只是瞎了眼。在对话框 fragment 中,我膨胀了一些自定义布局。 该按钮上未使用任何样式。我使用 Holo.Light 作为主题。但是按钮不是 以那种扁平的风格。

我该如何存档?

干杯, 风筝冲浪者

最佳答案

您必须设置正确的样式。我正在使用以下内容(应该适用于 HoneyComb+):

<LinearLayout
    style="?android:attr/buttonBarStyle"
    android:layout_width="match_parent"
    android:layout_height="48dp">

    <Button
        android:id="@+id/positive"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:drawableLeft="@drawable/ic_action_done"
        android:drawablePadding="8dp"
        android:gravity="start|center_vertical"
        android:padding="4dp"
        android:text="@string/done"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <Button
        android:id="@+id/negative"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:drawableLeft="@drawable/ic_action_cancel"
        android:drawablePadding="8dp"
        android:gravity="start|center_vertical"
        android:padding="4dp"
        android:text="@string/cancel"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>

关于android - 如何将 DialogFragment 上的按钮设置为平面样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15124511/

相关文章:

python - 时间间隔选择的最佳界面范例?

android - 如何显示全角 DialogFragment?

android - Jetpack compose dialogFragment 等效

android - 为什么在 Activity 被销毁时调用 DialogFragment.onCreateView?

java - 如何使 ListView 的全宽触摸敏感以便单击某个项目?

c++ - 如何根据 Qt 中的图形形状仅使按钮的一部分对用户操作(单击/如何/等)使用react?

android - 使用 ACTION_VIEW Intent 调用 YouTube 应用大部分时间都失败

Java Swing FlowLayout 对齐

android - 恢复快照后,模拟的 Android 设备不会重新同步时间/日期

java - 在新 Activity 中查看和下载壁纸时遇到问题