设置整个应用程序的alertDialog样式

时间:2018-11-18 17:17:20

标签: android styles alertdialog

我试图设置alertDialog的样式,不幸的是它不起作用。警报继续默认显示。 AppTheme有效,但AlertDialog的样式无效。

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorSecondaryDark</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:alertDialogTheme">@style/MyAlertDialogTheme</item>
    <item name="android:alertDialogStyle">@style/MyAlertDialogStyle</item>
</style>

   <style name="MyBorderlessButton">
        <item name="android:background">#777</item>
        <item name="android:textSize">8dp</item>
</style>

<style name="MyButtonBar">
    <item name="android:background">#000</item>
</style>

<style name="MyAlertDialogTitle">
    <item name="android:maxLines">1</item>
    <item name="android:scrollHorizontally">true</item>
</style>

<style name="MyAlertTextAppearance">
    <item name="android:textSize">30dp</item>
    <item name="android:textColor">@color/colorPrimaryDark</item>
</style>

<style name="MyAlertDialogTheme">
    <item name="android:windowBackground">@color/colorAccent</item>
    <item name="android:windowTitleStyle">@style/MyAlertDialogTitle</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowMinWidthMajor">@android:dimen/dialog_min_width_major</item>
    <item name="android:windowMinWidthMinor">@android:dimen/dialog_min_width_minor</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:textAppearanceMedium">@style/MyAlertTextAppearance</item>
    <item name="android:buttonBarStyle">@style/MyButtonBar</item>
    <item name="android:buttonBarButtonStyle">@style/MyBorderlessButton</item>
</style>

<style name="MyAlertDialogStyle">

</style>

0 个答案:

没有答案