旧版Android上的对话框样式不正确

时间:2015-04-05 13:57:34

标签: android android-dialog android-styles

我有警报对话框的样式:

<style name="Theme.Paper" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- customize the color palette -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:alertDialogStyle">@style/Theme.Paper.AlertDialogStyle</item>
    <item name="android:alertDialogTheme">@style/Theme.Paper.AlertDialog</item>
</style>

<style name="Theme.Paper.Toolbar" parent="Theme.Paper">
    <item name="android:textColorPrimary">@color/white</item>
    <item name="android:textColorSecondary">@color/white</item>
</style>

<style name="Theme.Paper.AlertDialogStyle" parent="android:Theme.Black">
    <item name="android:fullDark">@color/white</item>
    <item name="android:topDark">@color/white</item>
    <item name="android:centerDark">@color/white</item>
    <item name="android:bottomDark">@color/white</item>
    <item name="android:fullBright">@color/white</item>
    <item name="android:centerBright">@color/white</item>
    <item name="android:bottomBright">@color/white</item>
    <item name="android:bottomMedium">@color/white</item>
    <item name="android:centerMedium">@color/white</item>
</style>

<style name="Theme.Paper.AlertDialog.Title">
    <item name="android:maxLines">2</item>
    <item name="android:scrollHorizontally">true</item>
</style>

<style name="Theme.Paper.AlertDialog.TextAppearanceMedium">
    <!-- Set text size and color of message here -->
    <item name="android:textSize">16sp</item>
    <item name="android:textColor">@color/black_54</item>
</style>

<style name="Theme.Paper.AlertDialog.TextAppearanceLarge">
    <!-- Set text size and color of title -->
    <item name="android:textSize">20sp</item>
    <item name="android:textColor">@color/black_87</item>
</style>

<style name="Theme.Paper.AlertDialog" parent="android:Theme.Black">
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowTitleStyle">@style/Theme.Paper.AlertDialog.Title</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/Theme.Paper.AlertDialog.TextAppearanceMedium</item>
    <item name="android:textAppearanceLarge">@style/Theme.Paper.AlertDialog.TextAppearanceLarge</item>

    <item name="android:buttonBarStyle">@style/Theme.Paper.AlertDialog.ButtonBar</item>
    <item name="android:buttonBarButtonStyle">@style/Theme.Paper.FlatButton</item>
</style>

<style name="Theme.Paper.FlatButton">
    <!-- Set background drawable and text size of the buttons here -->
    <item name="android:background">@drawable/bg_dialog_button</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">@color/primary</item>
    <item name="android:layout_height">36dp</item>
    <item name="android:maxHeight">36dp</item>
    <item name="android:minHeight">36dp</item>
    <item name="android:minWidth">64dp</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:paddingLeft">8dp</item>
    <item name="android:paddingRight">8dp</item>
    <item name="android:layout_marginLeft">4dp</item>
    <item name="android:layout_marginRight">4dp</item>
</style>

<style name="Theme.Paper.AlertDialog.ButtonBar">
    <!-- Define a background for the button bar and a divider between the buttons here -->
    <item name="android:divider">@android:color/transparent</item>
    <item name="android:dividerPadding">0dp</item>
    <item name="android:showDividers">none</item>
    <item name="android:background">@color/white</item>
    <item name="android:layout_height">48dp</item>
    <item name="android:gravity">center_vertical|right</item>
</style>

在Android 4.x上看起来很正常,但在Android 2.x设备上我只有带按钮的白色对话框窗口(所有文本都是白色的,默认大小)

我该如何解决? 附:请帮我!由于这个原因,我无法发布我的应用程序......

0 个答案:

没有答案