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种方法,则需要手动处理对话框的取消按钮。

相关内容

热门资讯

来一盘!we poker辅助器... 来一盘!we poker辅助器v3.3,aapoker透视脚本入口,力荐教程(有挂透明);小薇(透视...
推荐十款!hhpoker免费透... 推荐十款!hhpoker免费透视脚本,wepoker黑侠辅助器,教你教程(有挂透明)科技教程也叫必备...
玩家交流!aapoker怎么拿... 玩家交流!aapoker怎么拿好牌,hh poker软件,扑克教程(有挂神器);原来确实真的有挂(需...
玩家必备科普!wepoker安... 玩家必备科普!wepoker安装教程,wepoker轻量版透视,攻略方法(有挂软件);实战中需综合运...
分享认知!hhpoker透视脚... 分享认知!hhpoker透视脚本,德州透视脚本,攻略方法(有挂攻略);玩家必备必赢加哟《136704...
总算清楚!德普之星怎么开辅助,... 总算清楚!德普之星怎么开辅助,wpk刷入池率脚本,2025教程(有挂技巧)科技教程也叫必备教程,这是...
科技通报!pokemmo手机脚... 科技通报!pokemmo手机脚本,newpoker怎么安装脚本,2025新版教程(有挂技巧)这是由厦...
三分钟了解!红龙poker辅助... 三分钟了解!红龙poker辅助器免费观看,wepokerplus脚本,技巧教程(有挂教程);亲真的是...
科技通报!hhpoker德州透... 科技通报!hhpoker德州透视挂,wejoker内置辅助,科技教程(有挂方法);小薇(透视辅助)致...
攻略讲解!wepoker透视底... 攻略讲解!wepoker透视底牌,wepoker免费辅助器,规律教程(有挂技巧)科技教程也叫必备教程...