NestedScrollView + ExpandableListView 显示不全问题和滑动冲突问题 。

昨晚美股中途再次熔断 。今天早上看我的支付宝的理财 ,收益 -7.24元 。

 

页面效果就不贴出来了  。想象一个效果滑动的 View 加上一个可展开收起滑动的 View 。

 

1. 首先是页面显示不全问题 

设置此行代码即可

android:fillViewport="true"

 

2. 滑动冲突问题

主要有两种 ,一个是根本滑不动 ,一个是只能滑动 ExpandableListView 。

需要重写 ExpandableListView 。

public class NestedExpandableListView extends ExpandableListView {

    public NestedExpandableListView(Context context) {
        super(context);
    }



    public NestedExpandableListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NestedExpandableListView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
                Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
        ViewGroup.LayoutParams params = getLayoutParams(); // 存在一个问题 ,如果是全部收起的话 ,就会导致页面空白
        params.height = getMeasuredHeight();
        
    }
}

 

PS :如果存在空白 ,可去 XML 布局里面调整 ExpandableListView 的相关位置属性 。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值