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

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

創(chuàng)新互聯(lián)公司是一家集做網(wǎng)站、成都網(wǎng)站制作、網(wǎng)站頁面設(shè)計、網(wǎng)站優(yōu)化SEO優(yōu)化為一體的專業(yè)網(wǎng)絡(luò)公司,已為成都等多地近百家企業(yè)提供網(wǎng)站建設(shè)服務(wù)。追求良好的瀏覽體驗,以探求精品塑造與理念升華,設(shè)計最適合用戶的網(wǎng)站頁面。 合作只是第一步,服務(wù)才是根本,我們始終堅持講誠信,負(fù)責(zé)任的原則,為您進(jìn)行細(xì)心、貼心、認(rèn)真的服務(wù),與眾多客戶在蓬勃發(fā)展的市場環(huán)境中,互促共生。

前言:

   關(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"/> 

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

網(wǎng)站題目:AndroidScrollView嵌套ExpandableListView顯示不正常的問題的解決辦法
鏈接URL:http://bm7419.com/article30/pciipo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航品牌網(wǎng)站制作、域名注冊網(wǎng)站設(shè)計公司、外貿(mào)網(wǎng)站建設(shè)、Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)