AndroidStudio:对话框框未保持与其自定义布局相同的格式
创始人
2024-08-21 12:00:15
0
  1. 确保在布局文件中设置了正确的布局参数(如宽度和高度),并确保对话框与布局文件具有相同的布局参数。

  2. 确保在对话框的代码中使用布局文件中的正确ID引用所有视图,如下所示:

    // Inflate the layout for this fragment View view = inflater.inflate(R.layout.dialog_layout, container, false);

    // Get references to the views defined in the layout EditText editText = view.findViewById(R.id.edit_text); Button button = view.findViewById(R.id.button);

  3. 如果对话框仍然未正确显示布局,则可以尝试使用以下代码更改对话框样式:

    Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false); dialog.setContentView(R.layout.dialog_layout); dialog.show();

    // Get references to the views defined in the layout EditText editText = dialog.findViewById(R.id.edit_text); Button button = dialog.findViewById(R.id.button);

注意:如果使用第3种方法,则需要手动处理对话框的取消按钮。

相关内容

热门资讯

透视实锤!aapoker怎么设... 透视实锤!aapoker怎么设置抽水(透视)ai插件(竟然有挂)运aapoker怎么设置抽水辅助工具...
透视安装!aa poker辅助... 透视安装!aa poker辅助(透视)透视脚本(本来真的有挂);1、aa poker辅助透视辅助简单...
透视有挂!aapoker免费透... 透视有挂!aapoker免费透视脚本(透视)透视脚本下载(好像是有挂);1、实时aapoker免费透...
透视好友!aapoker辅助怎... 透视好友!aapoker辅助怎么用(透视)真的假的(总是有挂)1、aapoker辅助怎么用系统规律教...
透视有挂!aapoker辅助插... 透视有挂!aapoker辅助插件工具(透视)辅助(切实是真的有挂);aapoker辅助插件工具软件透...
透视透视!aapoker免费透... 透视透视!aapoker免费透视脚本(透视)透视脚本(一直有挂);在进入aapoker免费透视脚本辅...
透视最新!aapoker辅助工... 透视最新!aapoker辅助工具安全吗(透视)真的假的(一贯真的是有挂);aapoker辅助工具安全...
透视挂!aapoker插件下载... 透视挂!aapoker插件下载(透视)脚本(好像存在有挂)1、下载好aapoker插件下载辅助软件之...
透视软件!aapoker真的假... 透视软件!aapoker真的假的(透视)真的假的(其实有挂)在进入aapoker真的假的辅助挂后,参...
透视教学!aapoker俱乐部... 透视教学!aapoker俱乐部靠谱吗(透视)ai插件(其实真的是有挂)1、首先打开aapoker俱乐...