国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android ScrollView嵌套ExpandableListView顯示不正常的問題的解決辦法

2019-10-23 19:48:23
字體:
來源:轉載
供稿:網友

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開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 凌海市| 自治县| 康马县| 涪陵区| 平武县| 正定县| 龙山县| 登封市| 乐昌市| 大姚县| 明溪县| 浪卡子县| 盘山县| 北川| 中宁县| 卓尼县| 长沙县| 安丘市| 左云县| 满洲里市| 巴彦淖尔市| 都兰县| 大姚县| 永顺县| 镇康县| 滨州市| 六枝特区| 芦溪县| 鄯善县| 偃师市| 上饶市| 岳普湖县| 岗巴县| 高陵县| 临夏县| 防城港市| 房产| 梓潼县| 容城县| 重庆市| 门源|