我想知道是否有人可以帮助我.我正在尝试创建自定义AlertDialog.为此,我在styles.xml中添加了以下代码行
<resources>
<style name="CustomAlertDialog" parent="android:Theme.Dialog.Alert">
<item name="android:windowBackground">@drawable/color_panel_background</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
以下是主要活动.
package com.customdialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
public class CustomDialog extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.setTheme(R.style.CustomAlertDialog);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("HELLO!");
builder .setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int …Run Code Online (Sandbox Code Playgroud) 我正在尝试从默认的android迁移AlertDialog到appCompat-22.1中包含的新的android 到目前为止我了解你只需导入android.support.v7.app.AlertDialog包以便使用它.
但我怎么样呢呢?例如,更改正/负按钮颜色,标题颜色,消息颜色和背景颜色?
android android-appcompat android-alertdialog android-support-library
我使用此命令更改了AlertDialog标题的颜色
alert.setTitle( Html.fromHtml("<font color='#FF7F27'>Set IP Address</font>"));
Run Code Online (Sandbox Code Playgroud)
但我想改变标题下出现的线条的颜色; 我怎样才能做到这一点 ?
注意:我不想使用自定义布局

我已经突破了这个问题.我需要做的是,AlertDialog在我的Android应用程序中更改所有s 的样式- 对话框背景需要是white-ish,文本需要是black-ish.我尝试创建了很多样式,主题,并从代码,清单等应用,但没有成功,关于内部的文本颜色AlertDialog.现在,我有最简单的代码,设置如下:
表现:
Run Code Online (Sandbox Code Playgroud)<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
styles.xml:
Run Code Online (Sandbox Code Playgroud)<style name="AppTheme" parent="AppBaseTheme"> <item name="android:alertDialogStyle">@style/DialogStyle</item> </style> <style name="DialogStyle" parent="@android:style/Theme.Dialog"> <!-- changing these background stuff works fine --> <item name="android:bottomBright">@android:color/white</item> <item name="android:bottomDark">@android:color/white</item> <item name="android:bottomMedium">@drawable/dialog_footer_bg</item> <item name="android:centerBright">@android:color/white</item> <item name="android:centerDark">@drawable/dialog_body_bg</item> <item name="android:centerMedium">@android:color/white</item> <item name="android:fullBright">@color/orange</item> <item name="android:fullDark">@color/orange</item> <item name="android:topBright">@color/green</item> <item name="android:topDark">@drawable/dialog_header_bg</item>
下面列出的项目不起作用(请阅读我在每个元素上面的评论):
Run Code Online (Sandbox Code Playgroud)<!-- panelBackground is not getting set to null, there is something squarish around it --> <item name="android:panelBackground">@null</item> <!-- Setting this textColor doesn't seem to have any effect at …