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. CSS单行超长溢出如何处理?表格某一行某一列超长如何处理?

    表格某一行某一列超长 截取一部分 并增加...效果 增加titile ======================================================== <td t ...

  2. SP2666 QTREE4 - Query on a tree IV(LCT)

    题意翻译 你被给定一棵n个点的带边权的树(边权可以为负),点从1到n编号.每个点可能有两种颜色:黑或白.我们定义dist(a,b)为点a至点b路径上的权值之和. 一开始所有的点都是白色的. 要求作以下 ...

  3. [BZOJ4530][Bjoi2014]大融合(LCT)

    传送门 大佬们似乎都是用树剖+并查集优雅地A了此题 然后我太弱了,只能打打LCT的板子 虽然的确可以挺无脑的A掉…… 不过至少这题教了我该怎么维护LCT上虚子树的信息,具体看这里 首先,答案很明显是断 ...

  4. [转贴]VC编译器版本号_MSC_VER and _MSC_FULL_VER

    Visual Studio version and discrimination macros Abbreviation Product name [Visual Studio version] †1 ...

  5. [独家] Adobe Flash 直接复制元件不改变原元件

    正在考网页高级考证,然后会需要做Adobe Flash相关操作.在网上看了下,基本都是错误的.于是,自己研究解决该问题. 首先,你需要更改元件不改变原文件是不可能的. 所以: 1.你需要对原元件所在的 ...

  6. python2-url编解码

    #coding:utf-8import urllibs={"username":"hhh","password":"XXXX&qu ...

  7. python-json.loads()保持原json字符串的顺序

    import jsonfrom collections import OrderedDictmetadata = json.loads(text, object_pairs_hook=OrderedD ...

  8. 【转】【C++专题】C++ sizeof 使用规则及陷阱分析

    提示:下文例子都经过Visual C++ 6.0验证,平台为win32 Windows. 一.什么是sizeof 首先看一下sizeof在msdn上的定义: The sizeof keyword gi ...

  9. php-elasticsearch bulk批量插入数据

    1.单条插入 <?php include '../vendor/Elasticsearch/autoload.php'; $a['hosts'] = array( #需要用户名时 http:// ...

  10. CSS z-index在ie67中不起作用

    在chrome浏览器中可以看到这样的效果: 但是在ie67中看到的是: 这是z-index在ie浏览器中的一个兼容性问题: 一般来说z-index越大,层级越高,就会越在顶层显示,但是在ie67浏览器 ...