Sweet Alert 中操作按钮的彩色背景 (Android)
Coloured Background of Action Button in Sweet Alert (Android)
我已经编写了一些代码来使用 sweet alert 库显示对话框。这是一个非常受欢迎的库,包含几个非常棒的功能,这些功能对于设计目的和开发目的都非常有用。所以请帮助更改出现在对话框底部的操作按钮的背景颜色。
我附上屏幕截图和代码。请帮我解决这个问题。
我只想更改操作按钮的背景颜色。
MaterialDialog.Builder builder = new MaterialDialog.Builder(SignInActivity.this)
.title("Sign Up")
.titleColor(Color.BLACK)
.customView(R.layout.custom_dialog_sign_up, true)
.positiveText("Submit")
.negativeText("Cancel")
.positiveColorRes(R.color.black_color)
.negativeColorRes(R.color.gray_btn_bg_color)
.canceledOnTouchOutside(false)
.autoDismiss(false);
final MaterialDialog materialDialog = builder.build();
materialDialog.show();
现在回答你的问题已经很晚了,但是,最近我遇到了这个问题,并开始在 google 上挖掘它,但一无所获,所以我自己开始,找到了这个完美的解决方案代码和屏幕截图附上。
SweetAlertDialog sweetAlertDialogView;
sweetAlertDialogView = new SweetAlertDialog(ctx,SweetAlertDialog.ERROR_TYPE);
sweetAlertDialogView.setTitleText(ctx.getResources().getString(R.string.error_msg_oops_title))
.setContentText("Request failed :" + errMsg + " \n" + ctx.getResources().getString(R.string.error_msg_check_net_connection));
sweetAlertDialogView.show();
Button viewGroup = (Button) sweetAlertDialogView.findViewById(cn.pedant.SweetAlert.R.id.confirm_button);
if (viewGroup != null) {
Log.e(TAG, "showErrorMsg: Button view Found yep");
viewGroup.setBackgroundColor(viewGroup.getResources().getColor(R.color.colorSkyBlueButtonLoader));
} else {
Log.e(TAG, "showErrorMsg: Button view Null :( ");
}
根据上面的逻辑,我将按钮颜色更新为深天蓝色,如需任何其他帮助,您可以在评论中询问我。我会尽力解决的。
完成此操作的更简单方法是仅覆盖 color.xml 中的以下颜色值:
<color name="blue_btn_bg_color">#1976D2</color>
<color name="blue_btn_bg_pressed_color">#1565C0</color>
我已经编写了一些代码来使用 sweet alert 库显示对话框。这是一个非常受欢迎的库,包含几个非常棒的功能,这些功能对于设计目的和开发目的都非常有用。所以请帮助更改出现在对话框底部的操作按钮的背景颜色。
我附上屏幕截图和代码。请帮我解决这个问题。
我只想更改操作按钮的背景颜色。
MaterialDialog.Builder builder = new MaterialDialog.Builder(SignInActivity.this)
.title("Sign Up")
.titleColor(Color.BLACK)
.customView(R.layout.custom_dialog_sign_up, true)
.positiveText("Submit")
.negativeText("Cancel")
.positiveColorRes(R.color.black_color)
.negativeColorRes(R.color.gray_btn_bg_color)
.canceledOnTouchOutside(false)
.autoDismiss(false);
final MaterialDialog materialDialog = builder.build();
materialDialog.show();
现在回答你的问题已经很晚了,但是,最近我遇到了这个问题,并开始在 google 上挖掘它,但一无所获,所以我自己开始,找到了这个完美的解决方案代码和屏幕截图附上。
SweetAlertDialog sweetAlertDialogView;
sweetAlertDialogView = new SweetAlertDialog(ctx,SweetAlertDialog.ERROR_TYPE);
sweetAlertDialogView.setTitleText(ctx.getResources().getString(R.string.error_msg_oops_title))
.setContentText("Request failed :" + errMsg + " \n" + ctx.getResources().getString(R.string.error_msg_check_net_connection));
sweetAlertDialogView.show();
Button viewGroup = (Button) sweetAlertDialogView.findViewById(cn.pedant.SweetAlert.R.id.confirm_button);
if (viewGroup != null) {
Log.e(TAG, "showErrorMsg: Button view Found yep");
viewGroup.setBackgroundColor(viewGroup.getResources().getColor(R.color.colorSkyBlueButtonLoader));
} else {
Log.e(TAG, "showErrorMsg: Button view Null :( ");
}
根据上面的逻辑,我将按钮颜色更新为深天蓝色,如需任何其他帮助,您可以在评论中询问我。我会尽力解决的。
完成此操作的更简单方法是仅覆盖 color.xml 中的以下颜色值:
<color name="blue_btn_bg_color">#1976D2</color>
<color name="blue_btn_bg_pressed_color">#1565C0</color>