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.

最新文章

  1. C/C++实践笔记 004
  2. &12 二叉搜索树
  3. Object转bigdecimal
  4. 为什么super()和this()调用语句不能同时在一个构造函数中出现的解释
  5. ios开发--KVO浅析
  6. Java [Leetcode 292]Nim Game
  7. Python的传值和传址与copy和deepcopy
  8. AngularJs项目
  9. hyper-v新内容
  10. oracle去除字符串中间的空格
  11. iOS开发--in house发布和安装(ipa重新签名)
  12. android面试题2
  13. 读 《 Web 研发模式的演变 》与《Javascript:世纪机器语言》
  14. python的sorted
  15. 【4】数独(Sudoku Killer)(深度优先遍历)
  16. OSI网络七层协议+火了火了火
  17. P3379 【模板】最近公共祖先(LCA)(树链剖分)版
  18. 026_关于shell中的特殊变量$0 $n $* $@ $! $?
  19. (GoRails)使用vue和Vuex管理嵌套的JavaScript评论, 使用组件vue-map-field
  20. 无用之flask

热门文章

  1. is 与 == 的区别;小数据池; 编码与解码
  2. Redis + Redis-sentinel + keepalived部署过程
  3. jquery源码解析:jQuery原型方法init的详解
  4. linux使用rsync、inotify-tools实现多台服务器文件实时同步
  5. 使用cookie下次自动登录
  6. c++11 perfect forwarding
  7. Linux-Web应用服务性能测试初探
  8. TD-LTE技术原理与系统设计
  9. 持续集成、持续交付、持续部署、Jkens、git
  10. FileZilla上傳報錯:421 There are too many connections from your internet address