网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 生活知识 知识问答

Android:设置AlertDialog的显示大小

时间:2026-02-15 11:11:33

1、1)更改AlertDialog窗口大小的方法:

AlertDialog dialog = new AlertDialog.Builder

(this).create();

dialog.show();

WindowManager.LayoutParams params = 

dialog.getWindow().getAttributes();

params.width = 200;

params.height = 200 ;

dialog.getWindow().setAttributes(params);

注意:是先显示出来dialog,show()出来,才能再设置宽高属性

2、2)去除边框

AlertDialog.setView(view,0,0,0,0);

© 2026 智德知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com