flx*_*pps 1 android android-appcompat android-theme android-alertdialog
我通过以下方式主题:
<!-- 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>
Run Code Online (Sandbox Code Playgroud)
但是,当我在我的应用程序中创建AlertDialogs时,它们根本不是主题.其他组件如ActionBar正在正确着色.我错过了什么吗?
我使用的是AppCompat版本com.android.support:appcompat-v7:23.1.1,我的设备安装了Android 4.4.4.
flx*_*pps 10
对于遇到类似问题而遇到这个问题的人:请仔细检查您是否正在使用支持库包中的AlertDialog.Builder,因此import语句应如下所示:
import android.support.v7.app.AlertDialog;
Run Code Online (Sandbox Code Playgroud)
在我的情况下,我进口android.app.AlertDialog导致了错误的结果.