4

我正在尝试更改对话的整个主题。

这是我的对话框的样式:

<style name="DialogWindowTitleText">
    <item name="android:textSize">28sp</item>
    <item name="android:textColor">@color/PRIORITY_HIGH</item>
</style>
<style name="CustomDialogWindowTitle">
    <item name="android:maxLines">1</item>
    <item name="android:scrollHorizontally">true</item>
    <item name="android:textAppearance">@style/DialogWindowTitleText</item>
</style>
<style name="CustomDialog" parent="android:Theme.Dialog" >
    <item name="android:textColor">#00FF00</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textSize">10sp</item>
    <item name="android:windowBackground">@color/orange</item>
    <item name="android:windowTitleStyle">@style/CustomDialogWindowTitle</item>

    <item name="android:textAppearance">@style/DialogWindowTitleText</item>
    <item name="android:textAppearanceInverse">@android:style/TextAppearance.Inverse</item>

    <item name="android:textColorPrimary">@color/blue</item>
    <item name="android:textColorSecondary">@color/blue</item>
    <item name="android:textColorTertiary">@color/blue</item>
    <item name="android:textColorPrimaryInverse">@color/blue</item>
    <item name="android:textColorSecondaryInverse">@color/blue</item>
    <item name="android:textColorTertiaryInverse">@color/blue</item>
    <!--<item name="android:textColorPrimaryDisableOnly">@android:color/primary_text_dark_disable_only</item>
    <item name="android:textColorPrimaryInverseDisableOnly">@android:color/primary_text_light_disable_only</item>-->
    <item name="android:textColorPrimaryNoDisable">@color/blue</item>
    <item name="android:textColorSecondaryNoDisable">@color/blue</item>
    <item name="android:textColorPrimaryInverseNoDisable">@color/blue</item>
    <item name="android:textColorSecondaryInverseNoDisable">@color/blue</item>
    <item name="android:textColorHint">@color/blue</item>
    <item name="android:textColorHintInverse">@color/blue</item>
</style>

这是我用来创建对话框的代码:

AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getContext(), R.style.CustomDialog));
    builder.setTitle(this.getTitleText());
    builder.setItems(itemsID, this);
    builder.show();

API 10 和 API 17 没有任何变化。

4

1 回答 1

2

您可以使用库 StyledDialogs,它使对话框的样式变得超级简单。您将在 API 级别 10 和 17 上看到相同的外观:

https://github.com/inmite/android-styled-dialogs

于 2013-06-12T07:48:21.003 回答