日期选择器对话框阴影的白色背景 [英] white background for date picker dialog shadow

查看:116
本文介绍了日期选择器对话框阴影的白色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将datepicker添加到应用程序中,但是问题是对话框的阴影具有白色背景,请使用Android 21进行编译.

I add datepicker to my application but my problem the shadow for the dialog have white background , use Android 21 for compile .

请帮我去除白色背景...

please help me to remove white background ...

推荐答案

您的themes.xmlstyles.xml材质设计支持库中有一个错误",无法与对话框配合使用.

You have a "bug" in your themes.xml or styles.xml material design support library is not working properly with dialogs.

因此,请删除特定的对话框代码或将其分成不同的版本.

So remove the specific dialog code or separate it in different versions.

尝试进一步解释.

通常,当我们扩展原始应用程序主题时,在values文件夹下有一个themes.xml和/或styles.xml文件.在其中的代码中,您将找到以下内容:

Generally when we extend the original application theme we have an themes.xml and/or styles.xml files under the values folder. In there code you will find something like these:

应用主题:

<style name="MyTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <!-- ... other styling values ...  -->

    <!-- Dialog attributes -->
    <item name="dialogTheme">@style/MyTheme.Dialog</item>
    <!-- AlertDialog attributes -->
    <item name="alertDialogTheme">@style/MyTheme.Dialog</item>

    <!-- ... other styling values ...  -->
</style>

自定义对话框主题:

<style name="MyTheme.Dialog" parent="@style/Theme.AppCompat.Light.Dialog">
    <!-- some styling values here -->
</style>

需要自定义的是MyTheme.Dialogparent,此Theme. AppCompat .Light.Dialog不适用于所有android版本,可能适用于Lollipop,但不起作用用于KitKat,或相反.

What needs customization is the parent of the MyTheme.Dialog this Theme.AppCompat.Light.Dialog does not work properly for all android versions it may work for Lollipop but does not work for KitKat, or the opposite.

  • 通过在每个平台上简单运行该应用程序,您可以轻松确定其在哪个版本中工作.
  • 然后,您可以为values-v21创建一个不同的文件夹,并相应地定义对话框的父级,以便它在两个版本中均适用.
  • With a simple run of the app in each platform you can easily find out in which version it works.
  • Then you can create a different folder for values-v21 and define the parent of the dialog accordingly, so that it work for both versions.

您可以应用其他有关样式自定义的变通方法,以使其正常工作.

You can apply some other workarounds regarding the customization of the style, in order for this to work.

如果您想进一步研究,或者主题定制的想法,请查看android theme.xml的来源

If you would like further research, or theme customization ideas take a look at the source of android theme.xml here.

这篇关于日期选择器对话框阴影的白色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆