控件如下

         

写一个类

    public class OnViewGlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener {        private int maxHeight = 500;        private View view;             public OnViewGlobalLayoutListener(View view, int height) {            this.view = view;            this.maxHeight = height;        }             @Override        public void onGlobalLayout() {            if (view.getHeight() > maxHeight)                view.getLayoutParams().height = maxHeight;        }    }

设置如下:

    View view = findViewById(R.id.devicelist_layout);    view.getViewTreeObserver().addOnGlobalLayoutListener(new OnViewGlobalLayoutListener(view, 300));

转自:https://blog.haloxin.me/post/100.html

更多相关文章

  1. Android进程回收
  2. android 状态栏占位_Android(安卓)Studio 全屏沉浸式透明状态栏
  3. 【Android程序开发】EditText详解
  4. Android(安卓)兼容性测试(CTS)
  5. Android(安卓)layout_alignBottom 注意事项
  6. Android(安卓)View And Activity
  7. Android
  8. 多个控件跑马灯效果
  9. Android(安卓)控件 —— ListView

随机推荐

  1. android的多屏支持
  2. Android - TextView限制文本长度,英文占1
  3. Android入门:向TextView添加滚动条
  4. android主要有5中数据存储方式
  5. Android Spinner,下拉菜单的功能和用法
  6. Android开发指南1-框架主题-基础知识
  7. Android应用程序通过JNI控制LED
  8. Android笔记之二:改进的NotePad Demo
  9. 关于getSharedPreferences 使用注意条件
  10. android资源管理和使用资源 (2015.12.1)