[英]alertDialogTheme not working (AppCompat v23)
I am having a theme in the following way: 我通过以下方式拥有主题:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="colorAccent">@color/accent</item>
</style>
However, when I create AlertDialogs inside my app, they are not themed at all. 但是,当我在应用程序内部创建AlertDialogs时,它们根本没有主题。 Other components like the ActionBar are being colored properly. 其他组件(如ActionBar)的颜色正确。 Am I missing something? 我想念什么吗?
I am using the AppCompat version com.android.support:appcompat-v7:23.1.1
and my device has Android 4.4.4 installed. 我正在使用AppCompat版本com.android.support:appcompat-v7:23.1.1
并且我的设备安装了Android 4.4.4。
For anyone stumbling upon this question with similar problems: Please double-check that you are using the AlertDialog.Builder from the support library package, so the import statement should look like: 对于在类似问题上绊脚石的任何人:请仔细检查您是否正在使用支持库包中的AlertDialog.Builder,因此import语句应类似于:
import android.support.v7.app.AlertDialog;
In my case I was importing android.app.AlertDialog
which led to the wrong results. 就我而言,我正在导入android.app.AlertDialog
,这导致了错误的结果。
创建AlertDialog时,可以设置要使用的主题:
import android.support.v7.app.AlertDialog;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.