Android 取消 ExpandableListView 的分割线,解决ScrollView 嵌套 ExpandableListView的问题

ExpandableListView 的布局中加入 android:childDivider="@android:color/transparent" 可取消 分割线

Scroll 嵌套 ExpandableListView 条目显示不完整,解决如下:

/**
 * 重写ExpandableListView以解决ScrollView嵌套ExpandableListView
 * Created by Administrator on 2017/12/5.
 */

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);
    }

最后使用如下:

 <com.chebangyang.www.chebangyangstore.widget.CustomExpandableListView
                    android:id="@+id/act_order_list_rcy_view"
                    android:scrollbars="none"
                    android:overScrollMode="never"
                    android:background="@color/color_white"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:childDivider="@android:color/transparent"
                    />
原创文章 119 获赞 77 访问量 3万+

猜你喜欢

转载自blog.csdn.net/baidu_40389775/article/details/102658219