重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

AndroidScrollView嵌套ExpandableListView显示不正常的问题的解决办法

Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法

创新互联公司是一家集做网站、成都网站制作、网站页面设计、网站优化SEO优化为一体的专业网络公司,已为成都等多地近百家企业提供网站建设服务。追求良好的浏览体验,以探求精品塑造与理念升华,设计最适合用户的网站页面。 合作只是第一步,服务才是根本,我们始终坚持讲诚信,负责任的原则,为您进行细心、贴心、认真的服务,与众多客户在蓬勃发展的市场环境中,互促共生。

前言:

   关于ScrollView嵌套ExpandableListView导致ExpandableListView显示不正常的问题解决方法有很多,在这里介绍一种小编亲自测试通过的方法。

重写ExpandableListView:

实例代码:

package com.jph.view; 
 
import android.content.Context; 
import android.util.AttributeSet; 
import android.widget.ExpandableListView; 
 
/** 
 * 重写ExpandableListView以解决ScrollView嵌套ExpandableListView 
 *
导致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即可。

 

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!


分享标题:AndroidScrollView嵌套ExpandableListView显示不正常的问题的解决办法
链接地址:http://cqcxhl.cn/article/pciipo.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP