【发布时间】:2013-07-27 21:17:55
【问题描述】:
我正在尝试更改 AlertDialog.Builder 的按钮颜色,但我没有找到方法。
我想像在 HOLO 主题中一样将按钮和标题的颜色更改为白色。
请参阅以下 2 个屏幕截图以获取示例:
我看过这里:
How to change theme for AlertDialog
Change the style of AlertDialog
How to change the background of the custom alert dialog
所有这些都不适合我。
这是我的代码:
public void logInDialog()
{
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.dialogStyle);
AlertDialog.Builder builder = new AlertDialog.Builder(ctw);
builder.setTitle("Log in");
View prefView = View.inflate(this, R.layout.log_in, null);
//The rest of the code.........
}
这是我的样式代码:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="dialogStyle" parent="android:Theme.Dialog">
<item name="android:background">@color/white</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:button">@color/white</item>
</style>
</resources>
【问题讨论】: