【发布时间】:2019-04-14 13:44:10
【问题描述】:
我已经创建了一个这样的自定义警报对话框 -
remark_builder = new AlertDialog.Builder(this);
// Get the layout inflater
LayoutInflater inflater = this.getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the
// dialog layout
remark_builder.setCancelable(true);
final View dialogView = inflater.inflate(R.layout.add_remark_dialog, null);
remark_builder.setView(dialogView);
if (remark_dialog == null || !remark_dialog.isShowing()) {
remark_dialog = remark_builder.create();
remark_dialog.setCanceledOnTouchOutside(false);
remark_dialog.show();
}
我想在此警报对话框的左侧和右侧添加边距。
我在互联网上尝试了很多代码,但它强调设置警报对话框的宽度和高度。 我不想设置宽度和高度。我想在 MATCH_PARENT 的 AlertDialog 的左侧和右侧添加边距。
我当前的警报对话框如下所示:
我想添加 40 或 50 等边距,或者根据设备密度添加边距。这可能吗?
【问题讨论】:
-
你想让它变小吗?
-
是的,宽度。您确定提供的链接有效吗??
-
二进制 XML 文件第 2 行:膨胀类
出错。 -
请提供对话框的xml布局
标签: android android-layout android-alertdialog