关于强调色。您正在使用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>
更新于2015年4月23日:支持库版本22.1
新的support library v22.1
可以与对话框(Dialog)一起使用。
您可以使用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)
alertDialogTheme
属性,则无需将样式传递给AlertDialog.Builder
。 请参见此处。 - JJD