63 lines
2.3 KiB
Java
63 lines
2.3 KiB
Java
//package com.gh.common.view;
|
|
//
|
|
//import android.content.Context;
|
|
//import android.support.v7.widget.LinearLayoutManager;
|
|
//import android.support.v7.widget.RecyclerView;
|
|
//import android.view.View;
|
|
//import android.view.ViewGroup;
|
|
//
|
|
///**
|
|
// * Created by khy on 2017/3/30.
|
|
// */
|
|
//public class MeasureLinearLayoutManager extends LinearLayoutManager {
|
|
// int height;
|
|
// private int[] mMeasuredDimension = new int[1];
|
|
//
|
|
// public MeasureLinearLayoutManager(Context context) {
|
|
// super(context);
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
|
|
// int widthSpec, int heightSpec) {
|
|
// super.onMeasure(recycler, state, widthSpec, heightSpec);
|
|
// height = 0;
|
|
//
|
|
// try {
|
|
// for (int i = 0; i < getItemCount(); i++) {
|
|
// measureScrapChild(recycler, i,
|
|
// View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
|
// View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
|
|
// mMeasuredDimension);
|
|
// height = height + mMeasuredDimension[0];
|
|
// }
|
|
// } catch (Exception e) {
|
|
// e.printStackTrace();
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
|
|
// int heightSpec, int[] measuredDimension) throws Exception {
|
|
// View view = recycler.getViewForPosition(position);
|
|
// if (view.getVisibility() == View.GONE) {
|
|
// measuredDimension[0] = 0;
|
|
// return;
|
|
// }
|
|
// super.measureChildWithMargins(view, 0, 0);
|
|
// RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
|
|
// int childHeightSpec = ViewGroup.getChildMeasureSpec(
|
|
// heightSpec,
|
|
// getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
|
|
// p.height);
|
|
//
|
|
// view.measure(0, childHeightSpec);
|
|
// measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
|
|
// recycler.recycleView(view);
|
|
// }
|
|
//
|
|
// public int getRvHeight() {
|
|
// return height;
|
|
// }
|
|
//}
|