gpt4 book ai didi

android - 如何更改 Alertdialog 的背景图像

转载 作者:行者123 更新时间:2023-11-29 14:05:33 25 4
gpt4 key购买 nike

我创建了一个 AlertDialog。在这里我可以更改 AlertDialog 按钮的背景图像。现在可以更改按钮后面区域的背景图像吗?我已经把截图发给你了。这样你就会清楚我想要什么。这是我的代码:

AlertDialog.Builder start_dialog = new AlertDialog.Builder(this);

TextView start_dialog_title = new TextView(this);
start_dialog_title.setText(m_res.getString(R.string.strt_dialog_title));
start_dialog_title.setBackgroundResource(R.drawable.strt_dlg_tlt_bckgrnd);
start_dialog_title.setGravity(Gravity.CENTER);
start_dialog_title.setTextColor(Color.WHITE);
start_dialog_title.setTextSize(20);

TextView start_dialog_desc = new TextView(this);
start_dialog_desc.setText(Html.fromHtml(m_res.getString(R.string.strt_dialog_desc)));
start_dialog_desc.setPadding(10, 10, 10, 10);
start_dialog_desc.setBackgroundResource(R.drawable.strt_dlg_desc_bckgrnd);
start_dialog_desc.setGravity(Gravity.CENTER);
start_dialog_desc.setTextColor(Color.WHITE);
start_dialog_desc.setTextSize(15);

start_dialog.setCustomTitle(start_dialog_title);
start_dialog.setView(start_dialog_desc);

start_dialog.setPositiveButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});

AlertDialog alert = start_dialog.create();
alert.show();
((Button) alert.findViewById(android.R.id.button1)).setBackgroundResource(R.drawable.settings_but);

enter image description here

最佳答案

不要设置正按钮。在布局文件中有自己的按钮。那应该可以解决您的问题。

关于android - 如何更改 Alertdialog 的背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7281963/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com