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雙層嵌套實現(xiàn)三級樹形菜單
- Android ExpandableListView實現(xiàn)下拉刷新和加載更多效果
- Android ExpandableListView單選以及多選實現(xiàn)代碼
- Android listview ExpandableListView實現(xiàn)多選,單選,全選,edittext實現(xiàn)批量輸入的實例代碼
- Android 關于ExpandableListView刷新問題的解決方法
- Android 關于ExpandableListView去掉里頭分割線的方法
- Android UI控件ExpandableListView基本用法詳解
- Android改變ExpandableListView的indicator圖標實現(xiàn)方法
- Android中ExpandableListView的用法實例
- Android ExpandableListView展開列表控件使用實例
- Android ExpandableListView用法示例詳解
相關文章
Android AlertDialog實現(xiàn)分享對話框/退出對話框/下載對話框
這篇文章主要介紹了Android AlertDialog實現(xiàn)分享對話框/退出對話框/下載對話框的相關資料,需要的朋友可以參考下2016-04-04
詳解Flutter如何使用Completer實現(xiàn)防抖功能
防抖是用于確保時間內的所有觸發(fā)被合并成單一請求,在Flutter中,我們可以使用Completer 來實現(xiàn)防抖功能,下面我們就來看看具體實現(xiàn)方法吧2024-03-03
Android中TimePicker與DatePicker時間日期選擇組件的使用實例
這篇文章主要介紹了Android中TimePicker時間選擇與DatePicker日期選擇組件的使用實例,這兩個組件加上去的效果就是我們平時在iOS上設置鬧鐘時調整時間類似的滾動選項,需要的朋友可以參考下2016-04-04
Android中FloatingActionButton的顯示與隱藏示例
本篇文章主要介紹了Android中FloatingActionButton的顯示與隱藏示例,非常具有實用價值,需要的朋友可以參考下2017-10-10
Android中ScrollView 滑到頭部或尾部可伸縮放大效果
最近做項目遇到這樣的需求S當crollView 滑動到頂部,不能在滑動的時候,圖片可以下拉放大,松開又恢復,滑到底部沒有內容的時候,也有伸縮效果,下面通過實例代碼給大家介紹Android ScrollView 滑到頭部或尾部可伸縮放大功能,一起學習吧2017-03-03
Android 通過自定義view實現(xiàn)水波紋效果案例詳解
這篇文章主要介紹了Android 通過自定義view實現(xiàn)水波紋效果案例詳解,本篇文章通過簡要的案例,講解了該項技術的了解與使用,以下就是詳細內容,需要的朋友可以參考下2021-08-08
Android 中okhttp自定義Interceptor(緩存攔截器)
這篇文章主要介紹了Android 中okhttp自定義Interceptor(緩存攔截器)的相關資料,需要的朋友可以參考下2017-03-03
Android使用GridView實現(xiàn)橫向滾動效果
這篇文章主要為大家詳細介紹了Android使用GridView實現(xiàn)橫向滾動效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-07-07

