Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法
更新时间:2017年02月11日 11:50:35 作者:CrazyCodeBoy
这篇文章主要介绍了Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法的相关资料,需要的朋友可以参考下
Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法
前言:
关于ScrollView嵌套ExpandableListView导致ExpandableListView显示不正常的问题解决方法有很多,在这里介绍一种小编亲自测试通过的方法。
重写ExpandableListView:
实例代码:
package com.jph.view; import android.content.Context; import android.util.AttributeSet; import android.widget.ExpandableListView; /** * 重写ExpandableListView以解决ScrollView嵌套ExpandableListView *<br> 导致ExpandableListView显示不正常的问题 * @author jph * Date:2014.10.21 */ public class CustomExpandableListView extends ExpandableListView { public CustomExpandableListView(Context context) { super(context); // TODO Auto-generated constructor stub } public CustomExpandableListView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } public CustomExpandableListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }
在XML中将ExpandableListView替换为重写的ExpandableListView即可。
<com.jph.view.CustomExpandableListView android:id="@+id/elItems" android:layout_width="match_parent" android:layout_height="wrap_content"/>
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
您可能感兴趣的文章:
- Android ExpandableListView双层嵌套实现三级树形菜单
- Android ExpandableListView实现下拉刷新和加载更多效果
- Android ExpandableListView单选以及多选实现代码
- Android中ExpandableListView使用示例详解
- Android listview ExpandableListView实现多选,单选,全选,edittext实现批量输入的实例代码
- Android中使用Expandablelistview实现微信通讯录界面
- Android 关于ExpandableListView刷新问题的解决方法
- Android ExpandableListView使用方法案例详解
相关文章
mui.init()与mui.plusReady()区别和关系
给大家分享一下在使用MUI进行APP开发的时候,mui.init()与mui.plusReady()区别以及使用上不同之处。2017-11-11Android自定义processor实现bindView功能的实例
下面小编就为大家分享一篇Android自定义processor实现bindView功能的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2017-12-12Android开发笔记之Android中数据的存储方式(二)
我们在实际开发中,有的时候需要储存或者备份比较复杂的数据。这些数据的特点是,内容多、结构大,比如短信备份等,通过本文给大家介绍Android开发笔记之Android中数据的存储方式(二),对android数据存储方式相关知识感兴趣的朋友一起学习吧2016-01-01
最新评论