1. We can make it to play trick in code.

At Dialog's show function, after app has set contentView, we can add a GlobalLayoutListener on decorView's ViewTreeObserver. At the listener, we can check the decorView's height, if over the max height, just truncate it.

 private void resolveAlertDialogHeight() {
WindowManager wm = (WindowManager) mContext
.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay(); Point size = new Point();
display.getSize(size);
int height = size.y; final int maxHeight = (int) (height * 0.68); final View decorView = mWindow.getDecorView();
decorView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
int actualHeight = decorView.getMeasuredHeight(); WindowManager.LayoutParams l = mWindow.getAttributes();
if (actualHeight > maxHeight) {
l.height = maxHeight; mWindow.setAttributes(l);
} decorView.getViewTreeObserver()
.removeOnGlobalLayoutListener(this);
}
});
}

2. Modify windowBackground reference png.

The dot9 png referenced by android:windowBackground attr is the Dialog's background. We can modify this dot9 png, adding extra padding on top and bottom to limit the margin of Alert.

How to limit Dialog's max height?的更多相关文章

  1. [Algorithm] Find Max Items and Max Height of a Completely Balanced Binary Tree

    A balanced binary tree is something that is used very commonly in analysis of computer science algor ...

  2. java 数据类型:Stream流 对象转换为集合collect(Collectors.toList()) ;常用方法count,limit,skip,concat,max,min

    集合对象.stream() 获取流对象,对元素批处理(不改变原集合) 集合元素循环除了用for循环取出,还有更优雅的方式.forEach 示例List集合获取Stream对象进行元素批处理 impor ...

  3. flutter showModalBottomSheet max height

    static void showBuyServiceDialog(BuildContext context) { showModalBottomSheet( context: context, isS ...

  4. Splitter Control for Dialog

    原文链接地址:https://www.codeproject.com/Articles/595602/Splitter-Control-for-Dialog Introduction Yes, tha ...

  5. jQuery UI 实例 - 对话框(Dialog)(zhuan)

    http://www.runoob.com/jqueryui/example-dialog.html ************************************************* ...

  6. jQuery UI 对话框(Dialog) - 模态表单

    <!doctype html><html lang="en"><head> <meta charset="utf-8" ...

  7. jQuery Dialog弹出层对话框插件

    Dialog.js的相关注释已经添加,可以按照注释,进行相关样式的修改,适用于自定义的各个系统! dialog.js /** * jQuery的Dialog插件. * * @param object ...

  8. jquery ui中的dialog,官网上经典的例子

    jquery ui中的dialog,官网上经典的例子   jquery ui中dialog和easy ui中的dialog很像,但是最近用到的时候全然没有印象,一段时间不用就忘记了,这篇随笔介绍一下这 ...

  9. dialog

    function showDialog(){ var $by = $(window), obj = $('.dialog'), brsW = $by.width(), brsH = $by.heigh ...

随机推荐

  1. P4597 序列sequence

    传送门 题解 完全看不懂大佬们在说什么……特别是chen_zhe大佬写的…… 来说说个人的理解吧 大佬们说:考虑当前的数$x$和之前的最大数$y$,(默认$x<y$,因为如果$x>=y$已 ...

  2. Archlinux下virtualbox报错'/sbin/rcvboxdrv setup'

    因为刚刚换成archlinux系统,安装virtualbox的时候报错了.如下图: 可是怎么解决呢?我看了很多资料大多数是ubuntu的,没有archlinux的. 但是原理都差不多我借着也就研究出来 ...

  3. 搭建sftp并设置不同权限的多个用户

    一, 设置相关用户,用户组,ssh配置文件 mkdir -pv /opt/ftpsite/{admin,user1,user2} groupadd sftpadmins groupadd sftpus ...

  4. leetcode-766-Toeplitz Matrix(每一条对角线元素的比较)

    题目描述: A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now ...

  5. .net core webapi发布

    地址:https://www.cnblogs.com/laozhang-is-phi/p/9565227.html#autoid-5-1-0 地址2:https://www.cnblogs.com/f ...

  6. bzoj3280: 小R的烦恼(最小费用最大流)

    Description 小R最近遇上了大麻烦,他的程序设计挂科了.于是他只好找程设老师求情.善良的程设老师答应不挂他,但是要 求小R帮助他一起解决一个难题.问题是这样的,程设老师最近要进行一项邪恶的实 ...

  7. 更改Android编译软件版本(make/gcc/bision)

    一.make版本 1.下载make的压缩包 ftp://ftp.gnu.org/gnu/make/ 2.解压,安装 cd make-x.x ./configuration sh build.sh su ...

  8. centos7 装机配置及 mysql 安装过程

    打开网卡,使操作系统可以上网 1 ip add 查看网卡,lo是回环网卡可以忽略,ens33为实际网卡. [root@localhost ~]# ip add 1: lo: <LOOPBACK, ...

  9. React创建组件的三种方式比较

    推荐文章: https://www.cnblogs.com/wonyun/p/5930333.html 创建组件的方式主要有: 1.function 方式 2.class App extends Re ...

  10. 【C语言】-指针和字符串

    本文目录 字符串回顾 一.用指针遍历字符串的所有字符 二.用指针直接指向字符串 三.指针处理字符串的注意 说明:这个C语言专题,是学习iOS开发的前奏.也为了让有面向对象语言开发经验的程序员,能够快速 ...