haijiang
2018-06-25 586f13d3aa93fc3fdfed65021b1a17a17acf3321
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.moral.andbrickslib.views;
 
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.ViewGroup;
 
/**
 * author 姚智胜
 * version V1.0
 * Description: 在ScrollView中的RecyclerView 与RecyclerForScrollView同时使用
 * date 2016/11/21 23:38
 */
 
public class RecyclerViewForScrollView extends RecyclerView {
    public RecyclerViewForScrollView(Context context) {
        super(context);
    }
 
    public RecyclerViewForScrollView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }
 
    public RecyclerViewForScrollView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
 
    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
 
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
 
        ViewGroup.LayoutParams params = getLayoutParams();
        params.height = getMeasuredHeight();
 
        setNestedScrollingEnabled(false);
 
    }
}