关于原生dialog修改button颜色值和背景颜色

来源:互联网 发布:led控制软件下载 编辑:程序博客网 时间:2024/05/18 00:02
原生的dialog比较丑,需要设置dialog的字体颜色,框的背景颜色和button的颜色
 AlertDialog dialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)                .setIcon(R.mipmap.info_commit_ok)                .setTitle(getResources().getString(R.string.info_commit_success))                .setMessage(R.string.register_result)                .setPositiveButton("确定", new OnClickListener() {            @Override            public void onClick(DialogInterface dialog, int which) {                // TODO Auto-generated method stub                dialog.cancel();                startActivity(LoginActivity.class);                finish();            }        }).create();        dialog.setOnShowListener(new DialogInterface.OnShowListener() {            @Override            public void onShow(DialogInterface dialog) {                    //                Button positiveButton = ((AlertDialog) dialog)                        .getButton(AlertDialog.BUTTON_POSITIVE);                positiveButton.setBackgroundColor(getResources().getColor(R.color.main_color));                positiveButton.setTextColor(Color.WHITE);            }        });        dialog.show();