Android ScrollView嵌套ExpandableListView顯示不正常的問題的解決辦法
Android ScrollView嵌套ExpandableListView顯示不正常的問題的解決辦法
前言:
關(guān)于ScrollView嵌套ExpandableListView導(dǎo)致ExpandableListView顯示不正常的問題解決方法有很多,在這里介紹一種小編親自測試通過的方法。
重寫ExpandableListView:
實例代碼:
package com.jph.view;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ExpandableListView;
/**
* 重寫ExpandableListView以解決ScrollView嵌套ExpandableListView
*<br> 導(dǎo)致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雙層嵌套實現(xiàn)三級樹形菜單
- Android ExpandableListView實現(xiàn)下拉刷新和加載更多效果
- Android ExpandableListView單選以及多選實現(xiàn)代碼
- Android listview ExpandableListView實現(xiàn)多選,單選,全選,edittext實現(xiàn)批量輸入的實例代碼
- Android 關(guān)于ExpandableListView刷新問題的解決方法
- Android 關(guān)于ExpandableListView去掉里頭分割線的方法
- Android UI控件ExpandableListView基本用法詳解
- Android改變ExpandableListView的indicator圖標(biāo)實現(xiàn)方法
- Android中ExpandableListView的用法實例
- Android ExpandableListView展開列表控件使用實例
- Android ExpandableListView用法示例詳解
相關(guān)文章
Android用PopupWindow實現(xiàn)自定義overflow
這篇文章主要介紹了Android用PopupWindow實現(xiàn)自定義overflow的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11
詳解Flutter自定義應(yīng)用程序內(nèi)鍵盤的實現(xiàn)方法
本文將展示如何利用Flutter創(chuàng)建自定義鍵盤小部件,用于在自己的應(yīng)用程序中的Flutter TextField中輸入文本,感興趣的小伙伴可以了解一下2022-06-06
Mac OS下為Android Studio編譯FFmpeg解碼庫的詳細(xì)教程
這篇文章主要介紹了Mac OS下為Android Studio編譯FFmpeg解碼庫的詳細(xì)教程,包括NDK的配置和Android Studio的配置兩個部分的內(nèi)容,需要的朋友可以參考下2016-01-01
Android Textview實現(xiàn)顏色漸變滾動效果
這篇文章主要為大家詳細(xì)介紹了Android Textview實現(xiàn)顏色漸變滾動效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-10-10
Android使用ViewPager實現(xiàn)左右無限滑動
這篇文章主要為大家詳細(xì)介紹了Android使用ViewPager實現(xiàn)左右無限滑動,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-05-05

