改变AlertDialog的大小
来源:互联网 发布:上饶七天网络查分入口 编辑:程序博客网 时间:2024/06/05 18:23
在做安卓电视端的项目时,系统弹出的AlertDialog非常丑,还有长宽不合适,所以就想办法,第一种时弹出一个自定义的Activity,但是这种方式比较麻烦,所以看了文档,直接对修改AlertDialog的长宽,不使用系统默认的样式。
//设置弹出框 QRMainActivity.this为Acivity AlertDialog.Builder builder=new AlertDialog.Builder(QRMainActivity.this); AlertDialog dialog=builder.create(); //设置标题 dialog.setTitle("请连接网络!"); //设置图片 dialog.setIcon(R.drawable.app_icon); //设置确定按钮监听, 第一个参数有三种形式 // DialogInterface.BUTTON_POSITIVE 确定 // DialogInterface.BUTTON_NEGATIVE} 取消 // DialogInterface.BUTTON_NEUTRAL 忽略 dialog.setButton(DialogInterface.BUTTON_POSITIVE, "设置", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); //不做任何操作 dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "知道了", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); //先调用这个方法,然后才设置dialog的长宽 dialog.show(); //获取屏幕的长宽 WindowManager window=getWindowManager(); Display display=window.getDefaultDisplay(); int screenheight=display.getHeight(); int screenWidth=display.getWidth(); //设置弹出框的长宽 dialog.getWindow().setLayout(screenWidth/3,screenheight/4);
注意:必须调用dialog.show(),然后才设置dialog的长宽
0 0
- 改变AlertDialog 的大小
- 改变AlertDialog的大小
- 如何改变AlertDialog 的大小
- 如何改变AlertDialog 的大小
- 如何改变AlertDialog 的大小
- Android 改变AlertDialog的大小
- Android 改变AlertDialog中View字体的大小
- 修改AlertDialog的大小
- AlertDialog自定义View的用法+如何改变弹出框的大小
- 设置AlertDialog的大小位置
- 设置AlertDialog的大小位置
- 设置 AlertDialog窗口的大小
- 改变support中AlertDialog的样式
- 单独改变AlertDialog的显示Theme
- 改变层的大小
- 改变QMessageBox的大小
- 改变图像的大小
- 改变图片的大小
- 从头开始基于Maven搭建SpringMVC+Mybatis项目(4)
- javaweb---JavaBean总结
- MySQL创建用户与授权
- OnPaint和OnDraw的区别
- IDEA 快捷键
- 改变AlertDialog的大小
- Android事件分发机制详解
- 如何使用protobuf-net生成.cs(c#)文件
- 【OpenCV】功能说明:Samples里的Python实现
- Maven学习笔记二:Maven的基本用法
- Cortex-M3 (NXP LPC1788)之UART用法
- git log alias配置
- iOS新手求职(本人经历)
- CPU使用率的计算方法