日期选择器对话框阴影的白色背景 [英] white background for date picker dialog shadow
问题描述
我将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.xml
或styles.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.Dialog
的parent
,此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屋!