自定义可以设置最大高度的ListView
2018-03-27 00:13
399 查看
原文地址:http://blog.csdn.net/x1051340616/article/details/53036910
public class MaxListView extends ListView { /** * listview高度 */ private int listViewHeight; public int getListViewHeight() { return listViewHeight; } public void setListViewHeight(int listViewHeight) { this.listViewHeight = listViewHeight; } public MaxListView(Context context) { super(context); // TODO Auto-generated constructor stub } public MaxListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } public MaxListView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub if (listViewHeight > -1) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(listViewHeight, MeasureSpec.AT_MOST); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
lv_kechengbiaoqian.setListViewHeight(500);
相关文章推荐
- 自定义可以设置最大高度的ListView
- 一个可以设置最大高度的ListView
- UITextView自适应高度,同时可以设置最大高度, 类似于QQ微信输入框效果,支持表情的输入
- Android 获取ListView的高度,设置布局内控件超出布局部分可以显示
- android自定义ListView高度设置无效
- Android自定义View——可以设置最大宽高的FrameLayout
- 动态设置ListView可以显示的高度
- 计算并设置ListView的高度,防止嵌套ScrollView监听出现问题,(两种方法,一种自定义,一种测量)
- 自定义可以设置drawable大小的TextView
- listview设置item高度或间距
- ScorllView嵌套ListView时,动态设置ListView高度时的问题.
- 动态设置listview的高度
- 287_计算并设置ListView的高度
- 如何给自定义listview设置监听事件
- 获取并设置ListView高度的方法
- Android 动态设置ListView、GridView高度
- 自定义列表框,可以调整高度。
- scrollView嵌套listView,重新设置listview高度解决冲突,但打开activity之后,初始位置不是顶部解决方案
- 通过动态设置ListView高度来解决ScollView与ListView互相嵌套的问题
- android开发,设置listview的高度无效