关于强调色。您正在使用 AppCompat 主题,因此您应该从主题内的命名空间中删除 Android。
<style name="AppTheme_Light" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/abc1</item>
<item name="colorPrimaryDark">@color/abc2</item>
<item name="colorAccent">@color/abc3</item>
</style>
关于对话框。 AppCompat 不支持它(据我所知)。
您可以尝试在 values-v21 文件夹中使用此样式:
<style name="Theme" parent="FrameworkRoot.Theme">
<item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
</style>
<style name="Theme.AlertDialog" parent="android:Theme.Material.Light.Dialog.Alert">
<item name="android:colorPrimary">@color/demo_primary_color</item>
<item name="android:colorPrimaryDark">@color/demo_colorPrimaryDark</item>
<item name="android:colorAccent">@color/theme_accent_1</item>
</style>
23/04/2015 更新:支持库 V.22.1
新的support library v22.1 与对话框一起使用。
您可以使用android.support.v7.app.AlertDialog 或新的AppCompatDialog。
例如:
import android.support.v7.app.AlertDialog
AlertDialog.Builder builder =
new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("Dialog");
builder.setMessage("Lorem ipsum dolor ....");
builder.setPositiveButton("OK", null);
builder.setNegativeButton("Cancel", null);
builder.show();
并使用这样的样式:
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#FFCC00</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:background">#5fa3d0</item>
</style>
否则你可以在你当前的主题中定义:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- your style -->
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
</style>
然后在你的代码中:
import android.support.v7.app.AlertDialog
AlertDialog.Builder builder =
new AlertDialog.Builder(this);