我在Eclipse中创建了一个新的应用程序,目标版本为Jelly Bean。这是所有自动生成的代码。清单将应用程序主题设置为AppName:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
. . .
这意味着在值目录中用于样式的名称是AppBaseTheme:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
而 values-v14/styles.xml 则是:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
在退出之前,我创建了一个确认对话框:
case R.id.menu_quit:
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle(R.string.confirm_title)
.setMessage(R.string.confirm_text)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
结果对话框如下所示:
为什么ic_dialog_icon图标如此浅?它几乎不可见。我正在使用所有默认设置,我没有修改主题或任何颜色,系统不应该选择与其背景更有对比度的图标吗?我该如何修复它?
使用修复进行编辑
根据Tomik提供的信息,我阅读了android.R.attr.alertDialogIcon的文档,并进行了以下修复(用setIconAttribute()替换了 setIcon()
)
new AlertDialog.Builder(this)
.setIconAttribute(android.R.attr.alertDialogIcon)
.setTitle(R.string.confirm_title)
.setMessage(R.string.confirm_text)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
现在对话框看起来像这样:
.setIconAttribute(android.R.attr.????)
可以替换.setIcon(android.R.drawable.ic_dialog_info)
? - JFar