最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法
时间:2017-03-28 编辑:简简单单 来源:一聚教程网
Android ScrollView嵌套ExpandableListView显示不正常的问题的解决办法
前言:
关于ScrollView嵌套ExpandableListView导致ExpandableListView显示不正常的问题解决方法有很多,在这里介绍一种小编亲自测试通过的方法。
重写ExpandableListView:
实例代码:
代码如下 | 复制代码 |
packagecom.jph.view;
importandroid.content.Context; importandroid.util.AttributeSet; importandroid.widget.ExpandableListView;
/** * 重写ExpandableListView以解决ScrollView嵌套ExpandableListView * * @author jph * Date:2014.10.21 */ publicclassCustomExpandableListViewextendsExpandableListView {
publicCustomExpandableListView(Context context) { super(context); // TODO Auto-generated constructor stub }
publicCustomExpandableListView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub }
publicCustomExpandableListView(Context context, AttributeSet attrs, intdefStyle) { super(context, attrs, defStyle); // TODO Auto-generated constructor stub } @Override protectedvoidonMeasure(intwidthMeasureSpec,intheightMeasureSpec) { // TODO Auto-generated method stub intexpandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >>2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } |
在XML中将ExpandableListView替换为重写的ExpandableListView即可。
代码如下 | 复制代码 |
android:layout_width="match_parent" android:layout_height="wrap_content"/> |
相关文章
- Android 开发实现EditText 光标居右显示 04-26
- Android子控件超出父控件的范围显示出来方法 08-04
- android ListView中嵌套GridView不完全显示如何解决 01-02
- 解决Android中Listview显示错乱问题 12-04
- 深入分析Android中Listview显示错乱问题 12-01
- sora软件价格介绍 02-22